【PAT甲级】1023 Have Fun with Numbers (20 分)
题意:
输入一个不超过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 分)的更多相关文章
- 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 ...
- 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 ...
- 1023 Have Fun with Numbers (20 分)
1023 Have Fun with Numbers (20 分) Notice that the number 123456789 is a 9-digit number consisting ...
- PAT甲级:1136 A Delayed Palindrome (20分)
PAT甲级:1136 A Delayed Palindrome (20分) 题干 Look-and-say sequence is a sequence of integers as the foll ...
- 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 ...
- PAT 甲级 1054 The Dominant Color (20 分)
1054 The Dominant Color (20 分) Behind the scenes in the computer's memory, color is always talked ab ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
随机推荐
- idea选中文件时左侧菜单自动定位到文件所在位置
一:设置成自动定位,如图: 二:点击项目工程目录上的阻击按钮,自动定位
- C语言笔记 10_文件读写&预处理器
文件读写 上一章我们讲解了 C 语言处理的标准输入和输出设备.本章我们将介绍 C 程序员如何创建.打开.关闭文本文件或二进制文件. 一个文件,无论它是文本文件还是二进制文件,都是代表了一系列的字节.C ...
- 神经网络之反向传播算法(BP)公式推导(超详细)
反向传播算法详细推导 反向传播(英语:Backpropagation,缩写为BP)是"误差反向传播"的简称,是一种与最优化方法(如梯度下降法)结合使用的,用来训练人工神经网络的常见 ...
- JavaScript ES5类 原型 原型链 组合、原型、寄生式继承
ES5类 原型 原型链 继承 JavaScript中,原型是相对于构造函数(类)的叫法(或者说概念),原型链是相对于构造函数(类)的实例对象的叫法. 对于JavaScript对象,如果在对象自身上找 ...
- Bug搬运工-CSCvm33229:Environment summary not available on COS APs
还是关于温度的问题, Environment summary not available on COS APs CSCvm33229 Description Symptom:From WLC CL ...
- 【转】docker配置参数详解---/etc/docker/daemon.json完整参数
docker-daemon.json各配置详解 { “api-cors-header”:"", ——————在引擎API中设置CORS标头 “authorization-plugi ...
- SpringCloud全家桶学习之服务注册与发现及Eureka高可用集群搭建(二)
一.Eureka服务注册与发现 (1)Eureka是什么? Eureka是NetFlix的一个子模块,也是核心模块之一.Eureka是一个基于REST的服务,用于定位服务,以实现云端中间层服务发现和故 ...
- RemoteView设置高度
刚开始内层LinearLayout直接用 android:layout_height="match_parent" <?xml version="1.0" ...
- ASP.NET Core搭建多层网站架构【9.1-使用Autofac代替原生的依赖注入】
2020/01/30, ASP.NET Core 3.1, VS2019, Autofac.Extensions.DependencyInjection 5.0.1 摘要:基于ASP.NET Core ...
- PyQt5绘图API
PyQt5绘图API大全1.绘图API:绘制文本#1.文本 2.各种图形 3.图像#QPainter painter=QPainter() painter.begin() painter.end() ...