浙江大学PAT_甲级_1023. Have Fun with Numbers (20)

PTA 大数算法 7-4 Have Fun with Numbers (20分) 思路: 1.首先不考虑整数相乘,考虑大数算法 2.数字后移, 多位数乘一位数(大数算法), 通过hashM, hashN数组判断,输出(需要判断)!!!! 上代码 #include<bits/stdc++.h> #define MAX 45 int hashN[MAX], hashM[MAX]; using namespace std; int postpone(char a[], int n)//把数字后移 { int len = strlen(a); for(int i = 0; a[ 阅读详情

题目链接:点击打开链接

Notice that the number 123456789 is a 9-digit number consisting exactly the numbers from 1 to 9, with no duplication. Double it we will obtain 246913578, which happens to be another 9-digit number consisting exactly the numbers from 1 to 9, only in a different permutation. Check to see the result if we double it again!

Now you are suppose to check if there are more numbers with this property. That is, double a given number with k digits, you are to tell if the resulting number consists of only a permutation of the digits in the original number.

Input Specification:

Each input file contains one test case. Each case contains one positive integer with no more than 20 digits.

Output Specification:

For each test case, first print in a line "Yes" if doubling the input number gives a number that consists of only a permutation of the digits in the original number, or "No" if not. Then in the next line, print the doubled number.

Sample Input:
1234567899
Sample Output:
Yes
2469135798
大意是:给一串由[1,9]组成的数字s,数字*2后得到第二串数字s2,如果s2里的每一位数字组成的集合等于s每一位数字组成的集合,则输出“Yes”,,否则输出“No”

python代码:

s=raw_input()#input a string of digit
s=int(s)#String conversion to int
s2=str(s*2)#Double it
s=str(s)
flag=int(0)
for i in s2:
    #If s2 char does not appear in s and The number of occurrences are not equal.
    if i not in s or s2.count(i)!=s2.count(i):
        print 'No'
        flag=1
        break
for i in s:
    #If s char does not appear in s2.
    if i not in s2 or s2.count(i)!=s.count(i):
        if flag==0:
            print 'No'
        flag=1
        break
if flag==0:
    print 'Yes'
print s2


PTA-7-49 Have Fun with Numbers 阅读详情

相关推荐

易灵思FPGA-软件Efinity和Modelsim联仿设置

文章目录前言一、modelsim破解过程二、使用步骤1.引入库2.读入数据总结欢迎使用Markdown编辑器新的改变功能快捷键合理的创建标题,有助于目录的生成如何改变文本的样式插入链接与图片如何插入一段漂亮的代码片生成一个适合你的列表创建一个表格设定内容居中、居左、居右SmartyPants创建一个自定义列表如何创建一个注脚注释也是必不可少的KaTeX数学公式新的甘特图功能,丰富你的文章UML 图表FLowchart流程图导出与导入导出导入 前言 提示:这里可以添加本文要记录的大概内容: 例如:随着人工智

qq_35221855的博客 5386

PAT (Advanced Level) Practice 1023 Have Fun with Numbers(20分)【字符串】

Notice that the number 123456789 is a 9-digit number consisting exactly the numbers from 1 to 9, with no duplication. Double it we will obtain 246913578, which happens to be another 9-digit number con...

一只小羊 538

RealSense D435i深度相机实战:从像素坐标到三维空间的精准映射(Python实现)

本文详细介绍了使用RealSense D435i深度相机实现从二维像素坐标到三维空间坐标精准映射的两种Python实战方法:深度图反投影法与点云直接查找法。文章涵盖环境搭建、相机对齐、代码实现、性能对比及与YOLO等检测模型结合的进阶应用,并提供了关键的避坑指南和参数调优建议,帮助开发者在机器人、三维重建等项目中高效应用。

weixin_29291573的博客 388

浙大 | PTA 自测-4 Have Fun with Numbers (20分)

Notice that the number 123456789 is a 9-digit number consisting exactly the numbers from 1 to 9, with no duplication. Double it we will obtain 246913578, which happens to be another 9-digit number con...

赞美太阳的博客 1039

SSD训练自定义数据集实战:VOC格式标注与模型调参技巧

本文详细介绍了如何使用SSD模型训练自定义VOC格式数据集,包括数据标注工具选择、VOC数据集目录结构规范、数据集划分方法以及模型调参技巧。通过实战案例演示了SSD源码的关键修改点和训练参数优化策略,帮助开发者高效实现目标检测任务。

php55的博客 566

【Linux】—MySQL安装

本文主要介绍在Linux环境下安装MySQL的过程。

sodaloveer的博客 6397

7-49 Have Fun with Numbers(20 point(s))

Notice that the number 123456789 is a 9-digit number consisting exactly the numbers from 1 to 9, with no duplication. Double it we will obtain 246913578, which happens to be another 9-digit number con...

学习为主,偶尔扯淡 795

ENVI哨兵一号数据处理

使用ENVI+SarScape处理哨兵数据

Rjjjjj11的博客 2万+

0-4 Have Fun with Numbers

题目: Notice that the number 123456789 is a 9-digit number consisting exactly the numbers from 1 to 9, with no duplication. Double it we will obtain 246913578, which happens to be another 9-digit number consisting exactly the numbers from 1 to 9, only in a d

不兼容旧版本 247

YOLOv8/v9轻量化优化:剪枝30%+蒸馏提精,模型体积缩至4MB还能跑Jetson

剪枝:用敏感度分析找到“可牺牲的30%”,不碰核心特征;蒸馏:借大模型的“经验”补回精度,甚至反超原始小模型;量化:针对边缘设备特性优化量化策略,把体积和延迟压到最低。如果你的项目卡在边缘部署(速度慢/体积大),按“剪枝→蒸馏→量化”三步走,90%能在Jetson上跑通30FPS+的实时检测。需要轻量化模型文件(v8s/v9s剪枝蒸馏后权重)、剪枝工具和Jetson部署脚本的,评论区扣“轻量化”,直接发你可运行版本~

专注于Python爬虫开发,分享爬虫技巧、项目实战与反爬经验,使用Scrapy、BeautifulSoup等工具,解决数据抓取难题。 679

Aip1640、TM1640驱动程序

本文介绍了AIP1640/TM1640驱动芯片的编程实现,主要包括硬件接口定义和通信协议函数。通过宏定义配置时钟(CLK)和数据线(DIO)的GPIO控制,实现了I2C协议的启动、停止、字节发送等基本操作。核心函数AIP1640_Disp_Drive()完成显示驱动流程:先发送0x40命令设置地址自增模式,再发送0xC0起始地址和16字节显示数据,最后设置亮度参数。文中还包含5微秒延时函数、显示数据缓冲区定义,以及LED和数码管(SMG)的位映射注释说明。该代码适用于控制LED数码管显示,支持亮度调节功能。

zqx的博客 1417

[PAT-Advanced] A1023 Have Fun with Numbers (20)

文章目录A1023 Have Fun with Numbers (20point(s))Input Specification:Output Specification:Sample Input:Sample Output:CodeAnalysis Author: CHEN, Yue Organization: 浙江大学 Time Limit: 400 ms Memory Limit: 64 MB...

Duke 289

2025实战|C#上位机+STM32实现LED串灯控制:串口通信+PWM调光+自定义帧协议(附上下位机源码)

粘包:一次收到“BRIGHT:50LED_OFF”,解析完全错乱;乱码:串口波特率/编码不匹配,指令变成“??H??50”;丢帧:数据传输中少字符,比如“BRIGHT:5”,解析出亮度5而非50。因此我们设计字节级自定义帧协议协议先行:无论简单还是复杂场景,先定义清晰的帧协议,避免数据错乱;串口稳字当头:下位机用环形缓冲区接收,上位机加锁发送,避免丢包/粘包;跨线程必处理:C#上位机所有UI更新必须用Invoke,否则必崩溃;硬件是基础:接线、供电、共地这些细节,比代码更易出问题;

这里只有干货:从 Modbus 到 MES,从 YOLO 到工控机部署;65 篇现场排障案例,每篇都写到改哪一行。 769

PAT甲级 1023 Have Fun with Numbers (20分)

1023 Have Fun with Numbers (20分) 题目链接:PAT A 1023 题目大意:给出一个不超过20位的整数n,要求将这个数乘以2,然后于原始数作比较看看是否有新增的数字,有则输出Yes,没有则输出No。还要输出乘以2后的数。 思路分析:由于最大的数可能有20位,所以不能定义一般的整型变量int,long long int也不能解决问题,所以涉及到大整数运算的知识点。...

weixin_43684054的博客 339

老版QQ原生表情gif动态

这是老版的QQ表情,不过全是动态的的,Windows照片查看器是不会动的,可以右击用浏览器打开查看,再说一遍是老版的,只是分享给宁愿用老版也要动态的人。

最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版

Part-E1-SDIO-Specification-Ver4.00-Final-120220.pdf:最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版,包括SDIO 接口的外设,SDIO 接口官方协议等。

【PAT甲级】1023 Have Fun with Numbers (20分)

解题过程的小记录,如有错误欢迎指出。 难度:三星(大整数的加法问题+hash表应用,建议去背晴神的算法笔记大整数加减乘除相关内容,背的是思想,代码用自己熟悉的方式实现就可以了) 小导航~题目分析注意点我的解题过程思路bug代码dalao的代码借鉴点 题目分析 给出一个数n(不超过20位),求它的双倍数结果,看结果所包含的各位数是否与原来给出的数一一对应(这里强调一一对应是因为,从给出的例子可以发现9出现了两次,双倍后也出现了两次,说明内容和数量都要一致) 注意点 数n刚好卡在long long的范围上,如

SpicyChicken的自我修养 497

霍尼韦尔SoftMaster使用说明

霍尼韦尔SoftMaster使用说明

【PAT甲级A1023】Have Fun with Numbers (20分)(c++)

1023 Have Fun with Numbers (20分) 作者:CHEN, Yue 单位:浙江大学 代码长度限制:16 KB 时间限制:400 ms 内存限制:64 MB Notice that the number 123456789 is a 9-digit number consisting exactly the numbers from 1 to 9, with no duplication. Double it we will obtain 246913578, which happen

小庄同学的博客 323

温度PID控制PLC程序

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

PAT甲级 1023 Have Fun with Numbers

数值的位数大于等于20位,大于long long的取值范围要使用string保存 GitHub - ZouJiu1/PAT: 浙江大学PAT题目解答内容浙江大学PAT题目解答内容. Contribute to ZouJiu1/PAT development by creating an account on GitHub.https://github.com/ZouJiu1/PAT...

邹九的个人博客 138

【甲级PAT】-1023 Have Fun with Numbers (20 分)-大整数加法

题目描述 1023 Have Fun with Numbers (20 分) 如果一个数乘二倍之后的结果与原始数字每位数字(0-9)出现的次数相等,输出“Yes”及乘二倍之后的结果 否则“No”和乘二倍之后的结果 英语 original number:原始数字 permutation:排列(方式);组合(方式);置换 思路 ...

断言的博客 202

Have Fun with Numbers,,请大佬指点为什么提交结果是错的呀

自测-4 Have Fun with Numbers (20 分) Notice that the number 123456789 is a 9-digit number consisting exactly the numbers from 1 to 9, with no duplication. Double it we will obtain 246913578, which happen...

weixin_38732825的博客 249

7-4 Have Fun with Numbers (20分)

Notice that the number 123456789 is a 9-digit number consisting exactly the numbers from 1 to 9, with no duplication. Double it we will obtain 246913578, which happens to be another 9-digit number con...

qq_44461900的博客 616

00-自测4. Have Fun with Numbers (20)

原文链接:http://www.patest.cn/contests/mooc-ds/00-%E8%87%AA%E6%B5%8B4 00-自测4. Have Fun with Numbers (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Sta

ice_camel的专栏 1216

PAT 1023. Have Fun with Numbers (20)

Notice that the number 123456789 is a 9-digit number consisting exactly the numbers from 1 to 9, with no duplication. Double it we will obtain 246913578, which happens to be another 9-digit number c...

学习,分享,总结 669

Have Fun with Numbers PTA

7-49 Have Fun with Numbers(20 分) 文章目录7-49 Have Fun with Numbers(20 分)前言题目:1.参考代码总结 前言 大一新生,自学C语言一个月,第一次写博客,希望借写博客进行总结反思,并记录当下的一些想法,在写博客的过程中精简一下原先写过的代码 题目: Have Fun with Numbers (20分) 作者 陈越 单位 浙江大学 代码长度限制 16 KB 时间限制 400

weixin_51960773的博客 578

1023. Have Fun with Numbers (20)-PAT甲级真题(大整数运算)

1023. Have Fun with Numbers (20) Notice that the number 123456789 is a 9-digit number consisting exactly the numbers from 1 to 9, with no duplication. Double it we will obtain 246913578, which happen

柳婼 の blog 2896

PAT甲级 1023 Have Fun with Numbers(20) (高精度)

PAT甲级 1023 Have Fun with Numbers(20) (高精度)

NHS6671的博客 267

PAT甲级真题-1023 Have Fun with Numbers详解优化

1023 Have Fun with Numbers 题目链接 https://pintia.cn/problem-sets/994805342720868352/problems/994805478658260992 解题思路 1.因为ungined long long 也无法记录20位数,因此只能用字符串来处理; 2.就是简单的对乘法的模拟,用一个变量记录每个数位乘以2产生的进位就可以了。嘿嘿 总结 想象平时算数学题的思路,模拟就好~~~。 代码展示 #include<bits/stdc++.h

高高冷的博客 337
上一篇: PAT_乙级_1003. 我要通过!(20)
下一篇: 浙江大学PAT_甲级_1024. Palindromic Number (25)
pythontojava
博客等级 码龄12年 84粉丝 140原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值
⌂ 换网址