题意:

输入一个不超过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. (原创)SoapUI学习(2)- POST请求

    1.新建Project,右键Projects->New REST Project,可以不填直接点击OK,之后通过rename重命名.(如果这里添加URL,则直接达到第三步的图) 2.右键新建的工 ...

  2. Linq Group by获取数量和数据

    主表: public partial class Activity { [Key] public int pkActivity { get; set; } public int fkEmployee ...

  3. vue中watch和computed为什么能监听到数据的改变以及不同之处

    先来个流程图,水平有限,凑活看吧-_-|| 首先在创建一个Vue应用时: var app = new Vue({ el: '#app', data: { message: 'Hello Vue!' } ...

  4. opencv python:图像金字塔

    图像金字塔原理 expand = 扩大+卷积 拉普拉斯金字塔 PyrDown:降采样 PyrUp:还原 example import cv2 as cv import numpy as np # 图像 ...

  5. js判断是横屏还是竖屏

    1通过在html中分别引用横屏和竖屏的样式: <link rel="stylesheet" media="all and (orientation:portrait ...

  6. 吴裕雄 python 神经网络——TensorFlow 图、张量及会话

    import tensorflow as tf g1 = tf.Graph() with g1.as_default(): v = tf.get_variable("v", [1] ...

  7. Linux修改本机/etc/hosts的hostName后经常不生效

    1.Linux修改本机别名/etc/hosts的hostName后经常不生效解决 Linux修改本机别名/etc/hosts的hostName后经常不生效, 比如我们/etc/hosts的内容如下: ...

  8. XMPPFramework 框架

    https://blog.csdn.net/qq_29846663/article/details/70170646 2017-04-14 11:37:02 于海明 阅读数 478更多 分类专栏: i ...

  9. kafka单机搭建

    1.安装jdk1.8和zookeeper 2.下载kafka上传服务器 下载地址:http://archive.apache.org/dist/kafka/0.10.0.0/kafka_2.11-0. ...

  10. Spring Boot Mybatis 使用教程

    Mybatis 在当下互联网开发环境,十分重要.本章主要讲述 Mybatis 如何使用. 从本系列开始,都需要用到 mysql 数据库 和其他一些参考的数据库.请准备相关环节.本章需要以下环境支撑: ...