浙江大学PAT_甲级_1024. Palindromic Number (25)

Bt下载.rar BitTorrent(简称BT)是一个文件分发协议,每个下载者在下载的同时不断向其他下载者上传已下载的数据。而在FTP、HTTP协议中,每个下载者从FTP或HTTP服务器处下载自己所需要的文件,各个下载者之间没有交互。 立即下载

题目链接:点击打开链接

A number that will be the same when it is written forwards or backwards is known as a Palindromic Number. For example, 1234321 is a palindromic number. All single digit numbers are palindromic numbers.

Non-palindromic numbers can be paired with palindromic ones via a series of operations. First, the non-palindromic number is reversed and the result is added to the original number. If the result is not a palindromic number, this is repeated until it gives a palindromic number. For example, if we start from 67, we can obtain a palindromic number in 2 steps: 67 + 76 = 143, and 143 + 341 = 484.

Given any positive integer N, you are supposed to find its paired palindromic number and the number of steps taken to find it.

Input Specification:

Each input file contains one test case. Each case consists of two positive numbers N and K, where N (<= 1010) is the initial numer and K (<= 100) is the maximum number of steps. The numbers are separated by a space.

Output Specification:

For each test case, output two numbers, one in each line. The first number is the paired palindromic number of N, and the second number is the number of steps taken to find the palindromic number. If the palindromic number is not found after K steps, just output the number obtained at the Kth step and K instead.

Sample Input 1:
67 3
Sample Output 1:
484
2
Sample Input 2:
69 3
Sample Output 2:
1353
3
回文数

python程序:

def check(str):
    left=int(0)
    right=len(str)-1
    while left<=right:
        if str[left]!=str[right]:
            return 0
        left=left+1
        right=right-1;
    return 1
a=[int(i) for i in raw_input().split()]
n=str(a[0])
k=int(a[1])
temp_int=0
count_k=0
for i in range(1,k+1):
    if check(n):
        break;
    temp_str=n[::-1]
    temp_int=int(n)+int(temp_str)
    n=str(temp_int)
    count_k=count_k+1
print n
print count_k


tk8610-src_tcl_c_www.9734hucom_WWW.TK27.C0M_tk_ tk8610 projectt k8610 project 立即下载

相关推荐

MSP430FR58xx59xx68xx69xx-.zip_www59xx_wwwxx69xxcon_xx59cOm_xx68x

如何从MSP430F5系列和F6系列移植到MSP430FR58xx59xx68xx69xx系列 希望对大家有用

物联网大数据实时分析平台

支持异构系统,实时上报数据(kafak、mqtt、rest等多来源)到flink,然后做实时分析或离线批处理,分析后的结果以多种形式保存/流转(kafak、mqtt、hdfs、mysql、redis 、hbase),底层以hadoop作为大数据存储与yarn资源管理,实战项目来源于商用项目二次设计,采用分布式高可用集群。本课程提供一键安装包,快速体验,从零基础学习角度设计并讲解,深入浅出,助您轻松掌握新一代流式计算与大数据分析全栈处理技术, 涵盖了真实业务全场景应用。同时提供包括: java微服架构设计、系统运维、docker、linux shell编程、node-red等相关知识详细讲解。本课程以EdgeXFoundry作为物联平台例示端。本系列课程可作为商业项目交付的基础框架、企业数据中台基础框架。

完整IC设计流程解析&Makefile学习

本文介绍了decorder38项目的文件结构、自动化综合流程和Makefile使用方法。项目包含RTL到GDSII全流程文件,重点关注syn目录中的综合脚本。通过make dc命令运行综合流程,生成网表、约束和时序文件。关键报告如qor.rpt、area.rpt和min_vio.rpt用于分析综合质量、面积和时序。Makefile部分解释了其基本语法、IC设计中的典型结构,包括目标定义、命令执行和特殊声明,强调了其在自动化构建和依赖管理中的重要性。

m0_63352623的博客 866

血腥大地-第二季(资源破解与管理)

课程继承游戏内容1.主要完成游戏资源的获取,从原血腥大地游戏中获取(不涉及任何商业利益,不能将游戏资源用于其他商业游戏).2.游戏资源的整理以及优化3.游戏纹理资源打包工具的制作4.游戏字体资源打包制作工具

华为OD机试新系统真题【迷宫相遇】

华为OD机试 新系统真题【迷宫相遇】,提供C语言、Java、C++、Python、Go、JavaScript源码实现,并提供完整思路讲解,以及在线OJ模拟做题。华为OD机试真题【迷宫相遇】多语言题解。

qq_45776114的博客 793

【水文学法总结】河道内生态流量计算方法(含MATLAB实现代码)

简介水文学法实现河道内生态流量计算

WW、forever的博客 5030

【PAT甲级A1024】 Palindromic Number (25分)(c++)

1024 Palindromic Number (25分) 作者:CHEN, Yue 单位:浙江大学 代码长度限制:16 KB 时间限制:400 ms 内存限制:64 MB A number that will be the same when it is written forwards or backwards is known as a Palindromic Number. For example, 1234321 is a palindromic number. All single digit

小庄同学的博客 203

第1.2章 机器人SLAM计算机基础总结(二):VSCode教程及 AI等效率插件推荐

如何高效编写代码?怎样快速调试程序?**别担心,今天就给大家带来一款超强大的编程神器 ——VSCode,以及能让编程之路 “一马平川” 的实用插件推荐,无论你是新手小白还是资深大神,都能从中受益!

行知SLAM 1875

PAT甲级 1024 Palindromic Number

数值可能越界long long,要用string保存并计算的 GitHub - ZouJiu1/PAT: 浙江大学PAT题目解答内容浙江大学PAT题目解答内容. Contribute to ZouJiu1/PAT development by creating an account on GitHub.https://github.com/ZouJiu1/PAT

邹九的个人博客 117

【Python基础】FastAPI 从入门到项目实战操作详解

【Python基础】FastAPI从入门到使用实战操作详解

congge_study的博客 487

python爬虫项目(六十八):爬取电商平台用户购买历史数据,分析消费行为

本文详细介绍了如何爬取电商平台用户购买历史数据,并分析其消费行为。通过爬虫技术、数据存储、分析和可视化等步骤,可以深入了解消费者的行为特征。未来,随着数据分析技术的不断发展,利用人工智能和机器学习方法对消费行为进行更深层次的分析,将成为电商平台提升竞争力的重要手段。

斌擎科技 2779

【题意分析】1024 Palindromic Number (25 分)_38行代码AC

立志用最少的代码做最高效的表达 PAT甲级最优题解——>传送门 A number that will be the same when it is written forwards or backwards is known as a Palindromic Number. For example, 1234321 is a palindromic number. All single digit numbers are palindromic numbers. Non-palindromic

weixin_43899069的博客 574

【C2000系列DSP的Bootloader详解】如何利用脚本自动合并Bin文件

本文通过OutconvertBin.py实现了 C2000 Bootloader+UserApp 的「ELF 转 BIN+BIN 合并」全流程自动化,核心优势如下: 架构适配:严格遵循 C28x 16 位大端格式,生成的 BIN 文件可直接烧录; 自动化程度高:一键完成清理、转换、合并,无需手动执行多个命令; 可追溯性:生成 CRC32 校验值,便于验证文件完整性; 量产友好:合并后的merged.bin支持一次性烧录,提升量产效率。

昔时扬尘处 194

BT 种子 tracker 磁链

传统的种子和磁链的区别 主要参考: https://www.quora.com/Whats-the-difference-between-magnet-links-and-regular-torrent-files-on-tracker-sites https://www.zhihu.com/question/36151980 (很多回答,但是都没有说清楚) 在使用迅雷时,磁链会先下载一个...

harryhare的专栏 12万+

Python 爬虫实战:Boss直聘 Python 岗位招聘数据爬取

本文介绍了一个Python爬虫项目,用于抓取Boss直聘平台的Python岗位招聘数据并进行可视化分析。项目采用requests库发送POST请求,通过抓包分析获取JSON接口,绕过HTML解析直接获取结构化数据。主要内容包括: 接口分析:找到关键POST接口,解析请求头和JSON参数格式 环境准备:安装requests/pandas/matplotlib/pyecharts等依赖库 核心实现: 手动获取登录Cookie 构建请求头和城市代码映射 实现分页抓取职位列表数据 项目特色在于直接解析JSON接口而

u014481728的博客 318

深度学习工具包 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")

DNSLog入门基础教程

课程从什么是DNSLog、讲解DNS解析流程、dnslog、XSS,RCE、SSRF、SQL注入。

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

从小白入门C语言

这是一门通俗易懂的C语言视频教程! C语言具有高效、灵活、功能丰富、表达力强和较高的可移植性等特点,在程序员中备受青睐,成为近25年使用为广泛的编程语言。目前市面上的C视频教程很多,但是千篇一律,枯燥乏味,并不适合新手!

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

Fast.ai 深度学习实战课程「中文字幕」

本课程由 Jeremy Howard 教授开设,共8节。目的是让大家在不需要深入研究高水平数学问题的情况下,学习如何建立先进的深度学习模型。Jeremy Howard 教授结合自己参加 Kaggle 大赛并夺魁的经验认为,传统学院派的教学方式对于大多数学习者来说已经不适用,应该以问题为引导,以实践为驱动,尽快切入到核心理论和核心工具的使用上,掌握深度学习优模型的构建方法。

1024,你懂的

哎呀,是不是被标题党套路了,不过认真读完,会有收获的哦,相信我。话说小拾君最近逛知乎,无意间被某些帖子指引,发现知乎已经快被1024攻占了,哈哈,然后今天准备跟大家科普一下1024。各位老司机们看看就好,千万不要开车....... 1024的起源。 经小拾君向诸多老司机求证,以及在度娘的帮助下,小拾君终于知道了1024的来历了。1024最早起源了某社区(什么社区,1024你懂的)为了防...

weixin_40876133的博客 33万+

1024

节日快乐

hc1428090104的博客 8万+

BT种子 & 磁力链接 是什么?

[科普向] BT 种子、磁力链接到底是什么? BitTorrent 我们平时所说的 BT 种子,实际上指的是由 BitTorrent 协议所生成的一个包含资源信息的文件。与传统的网络传输协议不同,BitTorrent 协议是一种以 Peer-To-Peer(P2P) ,即 用户对用户 模式为主的资源分享协议,采用的是一种 去中心化 的思想,不需要一个专门的文件发布者或者发布平台。 我们平常所使用的 HTTP、FTP 等协议需要一个 中心发布者 在网络上发布文件,即一种 点对多 的形式。当然,如果中心发布

weixin_43542745的博客 2万+

2025软考网络工程师--基础知识精讲视频

对软考网络工程师教材进行了详细解析,通过对考查知识点的细致讲解,让考生掌握解题思路和方法,做到举一反三,事半功倍。小任老师帮你把握考试重点,用短的时间,让你学到应该掌握的软考网络工程师内容。

边下边看的BT资源搜索下载工具:Tribler for Mac

为大家带来一款免费的BT资源搜索下载工具,Tribler for Mac可以通过分类搜索、关键词搜索或者按文件格式搜索网络上的BT资源,支持快速下载,而且Tribler Mac版还可以在完全下载之前播放BT视频,就跟迅雷一样,边下边看,亲测好用,这里准备了最新的Tribler免费版下载,欢迎各位来体验哦! ...

zjj778899的博客 4982

发现一个无敌多资源的资源库,里面的资源数不胜数

一群小蜜蜂的资源库

不想打代码 3304
上一篇: 浙江大学PAT_甲级_1023. Have Fun with Numbers (20)
下一篇: 浙江大学PAT_甲级_1027. Colors in Mars (20)
pythontojava
博客等级 码龄12年 84粉丝 140原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值
⌂ 换网址