题意:

输入一个不超过20位的正整数,问乘2以后是否和之前的数组排列相同(数字种类和出现的个数不变),输出Yes或No,并输出乘2后的数字。

AAAAAccepted code:

 #define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
int vis[];
string s;
int ans[];
int main(){
cin>>s;
int len=s.size();
for(int i=len-;i>=;--i)
++vis[s[i]-''];
int cnt=;
int x=;
for(int i=len-;i>=;--i){
x=(s[i]-'')*;
if(ans[cnt+]+x%>){
ans[++cnt]+=x%-;
++ans[cnt+];
}
else{
ans[++cnt]+=x%;
if(x>)
++ans[cnt+];
}
}
for(int j=;j;--j)
if(ans[j]){
cnt=j;
break;
}
for(int i=;i<=cnt;++i)
--vis[ans[i]];
int flag=;
for(int i=;i<;++i)
if(vis[i])
flag=;
if(flag)
cout<<"No\n";
else
cout<<"Yes\n";
for(int i=cnt;i;--i)
cout<<ans[i];
return ;
}

【PAT甲级】1023 Have Fun with Numbers (20 分)的更多相关文章

  1. PAT 甲级 1023 Have Fun with Numbers (20 分)(permutation是全排列题目没读懂)

    1023 Have Fun with Numbers (20 分)   Notice that the number 123456789 is a 9-digit number consisting ...

  2. PAT (Advanced Level) Practice 1023 Have Fun with Numbers (20 分) 凌宸1642

    PAT (Advanced Level) Practice 1023 Have Fun with Numbers (20 分) 凌宸1642 题目描述: Notice that the number ...

  3. 1023 Have Fun with Numbers (20 分)

    1023 Have Fun with Numbers (20 分)   Notice that the number 123456789 is a 9-digit number consisting ...

  4. PAT甲级:1136 A Delayed Palindrome (20分)

    PAT甲级:1136 A Delayed Palindrome (20分) 题干 Look-and-say sequence is a sequence of integers as the foll ...

  5. PAT 甲级 1023 Have Fun with Numbers(20)(思路分析)

    1023 Have Fun with Numbers(20 分) Notice that the number 123456789 is a 9-digit number consisting exa ...

  6. PAT 甲级 1054 The Dominant Color (20 分)

    1054 The Dominant Color (20 分) Behind the scenes in the computer's memory, color is always talked ab ...

  7. PAT 甲级 1027 Colors in Mars (20 分)

    1027 Colors in Mars (20 分) People in Mars represent the colors in their computers in a similar way a ...

  8. PAT 甲级 1005 Spell It Right (20 分)

    1005 Spell It Right (20 分) Given a non-negative integer N, your task is to compute the sum of all th ...

  9. PAT 甲级 1058 A+B in Hogwarts (20 分) (简单题)

    1058 A+B in Hogwarts (20 分)   If you are a fan of Harry Potter, you would know the world of magic ha ...

  10. PAT 甲级 1031 Hello World for U (20 分)(一开始没看懂题意)

    1031 Hello World for U (20 分)   Given any string of N (≥) characters, you are asked to form the char ...

随机推荐

  1. 无法创建“System.Object”类型的常量值。此上下文仅支持基元类型或枚举类型

    Entity FreamWork 无法创建“System.Object”类型的常量值.此上下文仅支持基元类型或枚举类型错误解决: 最近在开发中把我原来抄的架构里面的主键由固定的Guid改成了可以泛型指 ...

  2. 粪发涂墙-java1

    相信很多人和笔者一样,经常会做一些数组的初始化工作,也肯定会经常用到集合类.假如我现在要初始化一个String类型的数组,可以很方便的使用如下代码: String [] strs = {"T ...

  3. 红帽RHCE培训-课程2笔记目录

    目录 1 kickstart自动安装 DHCP+TFTP(syslinux) +FTP +KICKSTART ~/anaconda-ks.cfg system-config-kickstart 2 g ...

  4. Bugku-CTF加密篇之凯撒部长的奖励(就在8月,超师傅出色地完成了上级的特遣任务,凯撒部长准备给超师傅一份特殊的奖励.......)

    凯撒部长的奖励 就在8月,超师傅出色地完成了上级的特遣任务,凯撒部长准备给超师傅一份特殊的奖励,兴高采烈的超师傅却只收到一长串莫名的密文,超师傅看到英语字串便满脸黑线,帮他拿到这份价值不菲的奖励吧. ...

  5. vscode设置python代码补全时函数自动加上小括号

    vscode设置python代码补全时函数自动加上小括号 vscode的python代码补全插件默认安装时是不会自动补全括号的,感觉不是和方便 以下介绍下自动补上小括号的方法 可能部分同学设置了还是没 ...

  6. springMVC的概念

    1,完成一次web请求的过程 Web浏览器发起请求 Web服务器接收请求并处理请求,最后产生响应(一般为html).web服务器处理完成后,返回内容给web客户端,客户端对接收的内容进行处理并显示出来 ...

  7. window.onresize事件

    定义和用法 onresize 事件会在窗口或框架被调整大小时发生. 语法 In HTML: <element onresize="SomeJavaScriptCode"> ...

  8. JVM系列(四)之GC调优

    JVM内存参数调优 为什么要GC调优? 或者说的更确切一些,对于基于Java的服务,是否有必要优化GC?应该说,对于所有的基于Java的服务,并不总是需要进行GC优化,但当你的系统时常报了内存溢出或者 ...

  9. java作业 11.10

    package text3; import java.io.File; import java.io.IOException; import java.nio.file.Files; public c ...

  10. 消息队列(五)--- RocketMQ-消息存储1

    问题 : 部署时如何知道自己是 broker 还是 NameServer topic 订阅信息放在哪里 broker 的作用到底是什么 纪录是如何持久化的 群发的时候,是如何储存消息的 send 方法 ...