1939 Problem A 守形数

寻找1000以内的守形数(自守数) 本文介绍了守形数(自守数)的概念及其数学特性。守形数是指其平方末尾数字等于该数本身的自然数,如5(5²=25)、25(25²=625)等。文章详细阐述了守形数的数学原理,即满足n² ≡ n (mod 10^k),并提供了三种寻找守形数的算法:直接验证法、利用性质的生成法和数学公式法。通过Python代码实现,列举了1000以内的8个守形数(0,1,5,6,25,76,376,625),并验证了其正确性。此外,还探讨了守形数的无限性、对称性等有趣性质,为数学爱好者提供了扩展思考方向。 阅读详情

问题 A: 守形数

时间限制: 1 Sec  内存限制: 32 MB

题目描述

守形数是这样一种整数,它的平方的低位部分等于它本身。
比如25的平方是625,低位部分是25,因此25是一个守形数。
编一个程序,判断N是否为守形数。

输入

输入包括1个整数N,2<=N<100。

输出

可能有多组测试数据,对于每组数据,
输出"Yes!”表示N是守形数。
输出"No!”表示N不是守形数。

样例输入

6
11

样例输出

Yes!
No!

经验总结

基础题~~不多说啦~

AC代码

#include <cstdio>
#include <cstring>

int main()
{
	char n[4],l[6];
	while(~scanf("%s",n))
	{
		int pri;
		sscanf(n,"%d",&pri);
		sprintf(l,"%d",pri*pri);
		int flag=0,len=strlen(l)-1;
		for(int i=strlen(n)-1;i>=0;i--)
		{
			if(n[i]!=l[len--])
			{
				flag=1;
				break;
			}
		}
		if(flag==0)
			printf("Yes!\n");
		else
			printf("No!\n");
	}
	return 0;
}

 

判断一个数字是否是守形数 守形数是这样一种整数,它的平方的低位部分等于它本身。 比如25的平方是625,低位部分是25,因此25是一个守形数。 编一个程序,判断N是否为守形数。 立即下载

相关推荐

自守数C++实现

/*任意输入一个自然数,判断其是否为自守数,并输出相应的信息。自守数的定义为:一个自然数其本身平方后的数的尾数等于这个数本身。例如:25×25=625,76×76=5776。*/

求所有守形数 1 Sec

若某数的平方,其低位与该数相等,则称其为守形数。如25*25=625,625的低位与25相同,故25是守形数.现在要求输入一个正整数n,求2~n的守形数个数。输入一正整数n,(0

Chlero的博客 1467

开放词汇目标检测(Open-Vocabulary Object Detection, OVOD)综述

综上,大多数工作均基于CLIP预训练的图像编码器和文本编码器。GlIP为解决目标检测任务提供了先例,后续很多工作常与目前较为广泛使用的目标检测网络结构相结合,从而构建新的开放词汇目标检测器。如ViLD基于Mask R-CNN、RegionCLIP基于R-CNN、VLDet和BARON基于Faster R-CNN。更具有创新性的工作是Detic,提出了使用图像分类的数据集来对目标检测器的分类头进行训练。

yangsn0719的博客 4417

守形数

题目描述 守形数是这样一种整数,它的平方的低位部分等于它本身。 比如25的平方是625,低位部分是25,因此25是一个守形数。 编一个程序,判断N是否为守形数。 输入描述: 输入包括1个整数N,2<=N<100。 输出描述: 可能有多组测试数据,对于每组数据, 输出"Yes!”表示N是守形数。 输出"No!”表示N不是守形数。 示例1 输入 ...

422

educoder数字逻辑实训:寄存器设计与应用(Logisim)

第1关:基本寄存器的设计 任务描述 本关任务:在Logisim中,构建由4个D触发器构成的4位基本寄存器,要求上升沿触发,具有异步复位功能。 第2关:移位寄存器的设计 任务描述 本关任务:在Logisim中,构建由4个D触发器构成的4位右移移位寄存器,要求上升沿触发,具有异步复位功能。 第3关:循环移位寄存器的设计 任务描述 本关任务:在Logisim中,构建由4个D触发器构成的4位循环右移移位寄存器,要求上升沿触发,具有异步复位功能以及并行数据同步加载功能。 第4关:并行..

qq_52209002的博客 1万+

避坑指南:STM32F4的ADC采样FSR传感器,如何稳定读数并校准压力值?

本文详细解析了STM32F4的ADC采样FSR薄膜压力传感器时遇到的读数不稳定和非线性校准问题,提供了从硬件配置到软件滤波的完整解决方案。通过优化ADC设置、改进滤波算法和实施分段线性校准,帮助工程师实现高精度压力测量,特别适用于智能手套和医疗监测等应用场景。

weixin_28675839的博客 279

问题 A: 守形数

问题 A: 守形数 时间限制: 1 Sec 内存限制: 32 MB 献花: 48 解决: 39 [献花][花圈][TK题库] 题目描述 守形数是这样一种整数,它的平方的低位部分等于它本身。 比如25的平方是625,低位部分是25,因此25是一个守形数。 编一个程序,判断N是否为守形数。 输入 输入包括1个整数N,2 输出 可能有多组测试数据,对于每组数据, 输出”Yes

fantasydreams的专栏 939

Rider高效调试UE引擎:无需编译源码的符号配置指南

本文提供了一份详尽的Rider高效调试UE引擎指南,核心在于无需编译源码即可配置调试符号。通过Epic启动器下载官方PDB文件,并在Rider中正确配置外部符号服务器路径,开发者能在10分钟内实现对引擎内部代码(如AActor::Tick)的源码级断点调试、变量查看和调用堆栈分析,极大提升问题排查效率。

weixin_29011239的博客 347

题目1183:守形数

#include #include #include #include #include #include #include #include #include #include using namespace std; //1183 int main(){     int n,x,y;     //freopen("input.txt","r",stdin);     whi

Aden的专栏 467

H3C无线控制器二层注册实战:从零配置到AP上线全流程(附常见问题排查)

本文详细解析了H3C无线控制器二层注册的全流程,从网络基础准备、AC核心配置到AP上线,重点阐述了CAPWAP隧道建立的关键步骤。文章提供了清晰的典型配置示例,并针对AP无法上线、状态异常等常见问题,给出了六种典型故障现象的排查思路与解决命令,帮助网络工程师快速定位并解决问题。

weixin_29214199的博客 555

当AI写小说——一个被严重低估的工程化战场

摘要 AI小说创作远非简单的prompt生成,而是一项需要系统化工程管理的复杂任务。本文通过真实案例分析,揭示了当前AI写小说存在的五大核心难题:设定一致性难以维持、文风控制缺乏个性、爽感节奏难以把握、长篇记忆能力有限以及平台规则适配困难。研究显示,90%的失败案例源于错误的创作方法,主要表现为对话框式随机生成和模板式同质化创作。要实现高质量的AI小说创作,必须建立包括设定治理、记忆管理、文风校准等在内的全链路工程化体系,而非依赖单一prompt指令。只有采用系统化的人机协同方法,才能突破当前AI创作的质量

sellyogurt的博客 700

1939 Problem A 守形数

问题 A: 守形数 时间限制: 1 Sec 内存限制: 32 MB 提交: 723 解决: 322 题目描述 守形数是这样一种整数,它的平方的低位部分等于它本身。 比如25的平方是625,低位部分是25,因此25是一个守形数。 编一个程序,判断N是否为守形数。 输入 输入包括1个整数N,2<=N<100。 输出 可能有多组测试数据,对于每组数据, 输出"Yes!”表示N是守形数。 ...

weixin_43482621的博客 450

提示词编写:从新手到专家的进阶之路

本文旨在为提示词编写者提供一条从新手到专家的进阶之路。我们将详细探讨提示词编写的背景与意义、基础与进阶技巧、实战应用以及最佳实践。通过逐步深入的分析与实操,读者将掌握提示词编写的核心要点,提高编写效率和作品质量。提示词是用于引导人工智能生成文本的关键词或短语,它包含了作者想要传达的主题、情感和细节。随着人工智能技术的普及,自动化写作工具逐渐应用于各行各业。为了提高写作效率,项目团队决定开发一款基于人工智能的自动化写作工具。成功开发了一款自动化写作工具,生成文本质量较高。

AI天才研究院 1087

自守数习题

625,其中25等于625的低位部分,因此25是自守数。(注:0 和 1 也算自守数。所谓自守数(也称守形数),是指其平方数的低位部分恰为该数本身的自然数。由题目可知,首先将0和1的特殊情况单独列出,再考虑其他情况。一个正整数a,a≤10000。《C/C++简明双链教程》true或false。

2203_75901856的博客 575

lwip-2.0.3

lwip是瑞典计算机科学院(SICS)的Adam Dunkels 开发的一个小型开源的TCP/IP协议栈。实现的重点是在保持TCP协议主要功能的基础上减少对RAM 的占用。

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

守形数----java实现

守形数 public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); while (scanner.hasNext()){ int n = scanner.nextInt(); int m = n*n; ...

qq_45737438的博客 463

温度PID控制PLC程序

温度PID稳定控制程序,适用于欧姆龙PLC,对其他PLC也具有很大参考价值

华中科技大学 守形数(java)

题目描述 守形数是这样一种整数,它的平方的低位部分等于它本身。 比如25的平方是625,低位部分是25,因此25是一个守形数。 编一个程序,判断N是否为守形数。 输入描述: 输入包括1个整数N,2<=N<100。 输出描述: 可能有多组测试数据,对于每组数据, 输出"Yes!”表示N是守形数。 输出"No!”表示N不是守形数。 示例1 输入 复制 25 4 输出 复制 Yes! No!...

weixin_43306331的博客 614

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

华中科技大学 守形数

题目描述 守形数是这样一种整数,它的平方的低位部分等于它本身。 比如25的平方是625,低位部分是25,因此25是一个守形数。 编一个程序,判断N是否为守形数。 输入描述 输入包括1个整数N,2<=N<100。 输出描述 可能有多组测试数据,对于每组数据, 输出"Yes!”表示N是守形数。 输出"No!”表示N不是守形数。 示例 输入 25 4 输出 Yes! No! Code #...

星星点灯 452

判断守形数

编一个程序,判断N是否为守形数。

eCode代码加工厂 2237
上一篇: 5067 Problem A 求第k大数
下一篇: 1940 Problem B 反序数
漫浸天空的雨色
博客等级 码龄15年 1303粉丝 523原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值