题意:

输入一个不超过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. JavaScript - what is "this"? this是什么?

    https://fangyinghang.com/this-in-js/ Core func(p1, p2) // 等同于 func.call(undefined, p1, p2) this 就是ca ...

  2. Coursera-吴恩达机器学习课程笔记-Week1

    参考资料: 吴恩达教授机器学习课程 机器学习课程中文笔记 Week 1 一. 引言 机器学习模型可分为监督学习Superviese learning(每个数据集给出了正确的值)和无监督学习Unsupe ...

  3. SPRING MICROSERVICES IN ACTION

    What is microservice 背景 在微服务的概念成型之前,绝大部分基于WEB的应用都是使用单体的风格来进行构建的.在单体架构中,应用程序作为单个可部署的软件制品交付,所有的UI(用户接口 ...

  4. java 面试题 高阶版

    1.hash 算法问题 hash(n) /服务器个数 hash 算法在服务器增加或者减少的时候,数据存取位置为发生变化: 什么是一致性hash算法? 一致性hash算法对2^32 取模,整个Hash空 ...

  5. ubuntu16.04/ubuntu18.04安装网易云音乐

    一.下载1.0版本 下载地址:http://s1.music.126.net/download/pc/netease-cloud-music_1.0.0_amd64_ubuntu16.04.deb 下 ...

  6. php与js的false类型

    php除了下面列出来的情况是false  其余情况都可以看成true 包括NaN 和 空资源 整数 0 浮点数 0.0 空字符串 '' 或者'0' false 空数组 NULL类型 空标生成Simpl ...

  7. java.lang.IllegalStateException: This Activity already has an action bar supplied by the window decor. Do not request Window.FEATURE_SUPPORT_ACTION_BAR and set windowActionBar to false in your theme t

    异常信息: Caused by: java.lang.IllegalStateException: This Activity already has an action bar supplied b ...

  8. Vue.nextTick DOM 更新循环结束之后执行延迟回调

    在下次 DOM 更新循环结束之后执行延迟回调.在修改数据之后立即使用这个方法,获取更新后的 DOM. 简单来说,Vue 在修改数据后,视图不会立刻更新,而是等同一事件循环中的所有数据变化完成之后,再统 ...

  9. 01 认识python

    python介绍 python的创始⼈为吉多·范罗苏姆(Guido van Rossum).1989年的圣诞节期间,吉多·范罗苏姆为了在阿姆斯特丹打发时间,决⼼ 开发⼀个新的脚本解释程序,作为ABC语 ...

  10. 用python来更改windows开机密码

    今天教大家用python脚本来控制小伙伴们windows电脑的开机密码.没错就是神不知鬼不觉,用random()随机生成的密码,只有你自己知道哦~ 代码呢分两部分,一部分是client端跟server ...