PTA_Have fun with numbers(C++)


#include<iostream>
#include<cstring>
using namespace std;
int main()
{
int z=;
char fir[]="";
int sec[]={},thi[]={},fo[]={};
int len=;
cin>>fir;
len=strlen(fir);
int len2=len;
for(int i=;i<len;i++) sec[i]=fir[i]-'';
int i=len-;
for(i;i>;i--)
{
thi[i]=*sec[i]+z;
z=thi[i]/;
thi[i]%=;
}
int t=thi[i]; thi[i]=*sec[i]+z;
if(t>=)
{
len2++;
thi[i]=*sec[i]+z;
fo[]=thi[i]/ ;
thi[i]%=;
for(int j=;j<len;j++) fo[j+]=thi[j];
}
else
{
thi[i]=*sec[i]+z;
for(int j=;j<len2;j++) fo[j]=thi[j];
} z=;
for(int k=;k<len2;k++)
{
for(int j=;j<len;j++)
{
if(sec[j]==fo[k]){sec[j]=;z=;break;}
}
if(z!=) {z=;break;}
if(z==) z=; } if(z==)
{
cout<<"Yes"<<endl;
for(int j=;j<len2;j++) cout<<fo[j];
}
if(z!=)
{
cout<<"No"<<endl;
for(int j=;j<len2;j++) cout<<fo[j];
}
return ;
}
PTA_Have fun with numbers(C++)的更多相关文章
- Java 位运算2-LeetCode 201 Bitwise AND of Numbers Range
在Java位运算总结-leetcode题目博文中总结了Java提供的按位运算操作符,今天又碰到LeetCode中一道按位操作的题目 Given a range [m, n] where 0 <= ...
- POJ 2739. Sum of Consecutive Prime Numbers
Sum of Consecutive Prime Numbers Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 20050 ...
- [LeetCode] Add Two Numbers II 两个数字相加之二
You are given two linked lists representing two non-negative numbers. The most significant digit com ...
- [LeetCode] Maximum XOR of Two Numbers in an Array 数组中异或值最大的两个数字
Given a non-empty array of numbers, a0, a1, a2, … , an-1, where 0 ≤ ai < 231. Find the maximum re ...
- [LeetCode] Count Numbers with Unique Digits 计算各位不相同的数字个数
Given a non-negative integer n, count all numbers with unique digits, x, where 0 ≤ x < 10n. Examp ...
- [LeetCode] Bitwise AND of Numbers Range 数字范围位相与
Given a range [m, n] where 0 <= m <= n <= 2147483647, return the bitwise AND of all numbers ...
- [LeetCode] Valid Phone Numbers 验证电话号码
Given a text file file.txt that contains list of phone numbers (one per line), write a one liner bas ...
- [LeetCode] Consecutive Numbers 连续的数字
Write a SQL query to find all numbers that appear at least three times consecutively. +----+-----+ | ...
- [LeetCode] Compare Version Numbers 版本比较
Compare two version numbers version1 and version1.If version1 > version2 return 1, if version1 &l ...
随机推荐
- xgboost-Python&R
sklearn实战-乳腺癌细胞数据挖掘(博主亲自录制视频) https://study.163.com/course/introduction.htm?courseId=1005269003& ...
- Ubuntu几个常用命令
命令 > file 重定向,清空file文件 命令 >>file 重定向,不清空文件,在尾部追加 英文对照:
- 通过<meta>标签指定IE的文档模式实现CSS3兼容
今天发现之前做好的一个页面在IE中打开显示的效果不正常,本地和服务器上显示的是两种不同的样式. 经过确认文档内容和CSS都是一样的. 通过IE F12(开发人员工具)发现不正常的样式 浏览器文档模式自 ...
- 解决系统中大量的TIME_WAIT连接
今天发现网站特别卡!! 查看网络连接数: netstat -an |wc -l netstat -an |grep xx |wc -l 查看某个/特定ip的连接数 netstat -an ...
- APPLE-SA-2019-3-27-1 watchOS 5.2
APPLE-SA-2019-3-27-1 watchOS 5.2 watchOS 5.2 is now available and addresses the following: CFStringA ...
- Scanner输入数字时个位十位百位千位单独取出。
Scanner inn = new Scanner(System.in); int i = inn.nextInt(); System.out.println("个位是"+i%10 ...
- L1-Day13
1.Being late is an unforgivable sin here.[我的翻译]在北京,迟到是不可饶恕的罪名.[标准答案]在这里迟到是不可原谅的.[对比分析]对自己的也是醉醉的了,Bei ...
- ubuntu 装机必备
在github上下载高博的slambook(https://github.com/gaoxiang12/slambook)在3rdparty文件夹中有安装包. 1. 安装Eigen库 sudo apt ...
- 基于Python的Webservice开发(一)-简介
之前为了解决Webservice的开发,直接用Python自带的CGI模块挂在IIS上. 但是该方式开发Soap的接口,需要大量的开发,而且安全方面也存在很多问题. 我推荐关于用Python开发Web ...
- 项目Alpha冲刺——代码规范、任务及计划
代码规范 JS规范 JS规范在线预览 PHP规范 PHP规范在线预览 Unity C#脚本规范 C#规范下载 任务计划 图表 计划进度燃尽表 网站部分任务计划 任务 时间 内容 第一天 4.24 阅读 ...