#include<iostream>
#include<string>
#include<cstring>
#include<vector>
using namespace std;
int main()
{
int a[] = {}, b[] = { };
string str;
vector<int>doublenum;//记录翻倍后的数值
cin >> str;
int length = str.length();
int j = ;
for (int i = ; i < length; i++)
{
int num;
num = str[i] - '';
a[num]++;
}
int carry = ;
for (int i = length-; i>=; i--)
{
int num = (str[i] - '') * + carry;
if (num >=)
carry = ;
else
carry = ;
int remainder = num % ;
b[remainder]++;
doublenum.push_back(remainder);
}
if (carry == )
doublenum.push_back();
bool judge = true;
for (int i = ; i < ; i++)
{
if (a[i] != b[i])
{
judge = false;
break;
}
}
if (judge)
{
cout << "Yes" << endl;
}
else
{
cout << "No" << endl;
}
for (int i = doublenum.size()-; i>=; i--)
{
cout << doublenum[i];
}
return ;
}

1、用字符串记录数字

2、vector

PTA 自测-4 Have Fun with Numbers的更多相关文章

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

    00-自测4. Have Fun with Numbers (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 CHEN, Yu ...

  2. 数据结构练习 00-自测4. Have Fun with Numbers (20)

    Notice that the number 123456789 is a 9-digit number consisting exactly the numbers from 1 to 9, wit ...

  3. PTA自测-3 数组元素循环右移问题

    自测-3 数组元素循环右移问题  一个数组A中存有N(N>0)个整数,在不允许使用另外数组的前提下,将每个整数循环向右移M(M≥0)个位置,即将A中的数据由(A0A1···A​N-1​​)变换为 ...

  4. 自测-4 Have Fun with Numbers

    Notice that the number 123456789 is a 9-digit number consisting exactly the numbers from 1 to 9, wit ...

  5. 00-自测4. Have Fun with Numbers

    Notice that the number 123456789 is a 9-digit number consisting exactly the numbers from 1 to 9, wit ...

  6. PTA (Advanced Level) 1023 Have Fun with Numbers

    Have Fun with Numbers Notice that the number 123456789 is a 9-digit number consisting exactly the nu ...

  7. 『ACM C++』PTA浙大 | 基础题 - Have Fun with Numbers

    连着这两道都是开学前数构老师的“爱心作业”,还没上课开学就给我们布置作业了,这道题有点小坑,也经常遇到类似的问题,特地拿出来记录一下. -------------------------------- ...

  8. PAT自测_打印沙漏、素数对猜想、数组元素循环右移、数字加倍重排、机器洗牌

    -自测1. 打印沙漏() 本题要求你写个程序把给定的符号打印成沙漏的形状.例如给定17个“*”,要求按下列格式打印 ***** *** * *** ***** 所谓“沙漏形状”,是指每行输出奇数个符号 ...

  9. 201521123098 《Java程序设计》 第4周学习总结

    1. 本周学习总结 1.1 尝试使用思维导图总结有关继承的知识点. 1.2 使用常规方法总结其他上课内容. 1. 学习了继承的基本含义,用"class 子类名 extend 父类名" ...

随机推荐

  1. Docker PHP 例子

    版权所有,未经许可,禁止转载 章节 Docker 介绍 Docker 和虚拟机的区别 Docker 安装 Docker Hub Docker 镜像(image) Docker 容器(container ...

  2. [CISCN2019 华北赛区 Day1 Web5]CyberPunk

    0x00 知识点 PHP伪协议直接读取源码 http://xxx.xxx/index.php?file=php://filter/convert.base64-encode/resource=inde ...

  3. C++基础--函数模板

    函数模板是通用的函数描述,其使用泛型来定义函数.其实就是有些操作,如果撇开具体的变量的数据类型,其操作是一样的如果我们将这些操作写成一个模板,在调用不同变量的时候就设定好变量类型就可了,后续的操作基本 ...

  4. cf 730J. Bottles

    搞一个背包,233 要求用的瓶数最少,那么就业瓶数为第一关键,当瓶数相当后再以a[i] #include<bits/stdc++.h> #define N 100005 #define L ...

  5. 调用servlet报The requested resource is not available.

    调用servlet的时候经常有这种报错,一般来说我直到现在遇到的情况大致有以下几类: 1.参数写错了 在新创建的servlet文件中有这么一行代码,“/LoginCheck”这个一定要和form表单中 ...

  6. CSS font-family 各字体一览表

    windows常见内置中文字体字体中文名 字体英文名宋体                      SimSun(浏览器默认) 黑体                      SimHei 微软雅黑 ...

  7. 判断单链表是否有环,并找出环的入口python

    1.如何判断一个链表是否有环? 2.如果链表为存在环,如果找到环的入口点? 1.限制与要求 不允许修改链表结构. 时间复杂度O(n),空间复杂度O(1). 2.思考 2.1判断是否有环 如果链表有环, ...

  8. SQL笔记整理

  9. PAT 2019 秋

    考试的还行.不过略微有点遗憾,但是没想到第一题会直接上排序和dfs,感觉这次的题目难度好像是倒着的一样.哈哈哈哈. 第一题实在是搞崩心态,这道题给我的感觉是,可以做,但事实上总是差点啥. 第二题,第三 ...

  10. VUE.js入门学习(3)-深入理解VUE组建

    1.使用组件的细节点 (1)is="模版名" (2)在子组建定义data的时候,data必须是一个函数,而不能是一个对象,每个子组建都有自己的数据存储.之间不会相互影响. (3)操 ...