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 ...
随机推荐
- thrift使用
一.什么是thrift Thrift是一种接口描述语言和二进制通讯协议,它被用来定义和创建跨语言的服务.它被当作一个远程过程调用(RPC)框架来使用,是由FaceBook为“大规模跨语言服务开发”而开 ...
- mysql 关联表修改数据
UPDATE t1 INNER JOIN t2 ON t1.c1=t2.c1 SET t1.c2=value WHERE t1`removed`=0 AND t2`removed`=0 AND t1 ...
- R-----shiny包的部分解释和控件介绍
R-----shiny包的部分解释和控件介绍 作者:周彦通.贾慧 shinyApp( ui = fixedPage( fixedPanel( top = 50, right=50, width=200 ...
- P5283 [十二省联考2019]异或粽子
考场上想到了没打完,细节思路还是不是很优,我原先的想法是每一次找完后标记那个点,下次再继续找(并不是这个意思,说不清楚)但实际上和平衡树一样加个大小就很好写了 #include<bits/std ...
- Appnium-API-Dvice
Device Activity Start Activity Start an Android activity by providing package name and activity name ...
- Spring Cloud Commons模块
上一篇介绍了 Spring Cloud Context模块 ,本文介绍SpringCloud的另一个基础模块 SpringCloud Commons模块 .只要在项目的pom文件中引入了spring- ...
- java学习笔记06-条件语句
java条件语句 if...else 单独使用if if(布尔表达式){ 如果布尔表达式为true,执行花括号里的代码 } public static void main(String[] args) ...
- MailKit系列之转发电子邮件
原文:http://www.it1352.com/429181.html 问题 我尝试通过MailKit访问一个IMAP账号,我设法下载邮件(作为的MimeMessage),并在某些时候我需要转发给其 ...
- docker-compose部署ELK
本章基于 https://www.cnblogs.com/lirunzhou/p/10550675.html 在此基础上将ELK系统docker-compose.yml化. 其docker-compo ...
- dataguard丢失归档日志处理
检查alert日志发现报错如下 Wed Mar 27 15:40:30 2019Managed Standby Recovery not using Real Time ApplyParallel M ...