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 ...
随机推荐
- 对filter的初步认识
Filter 技术是servlet 2.3 新增加的功能.servlet2.3是sun公司 于2000年10月发布的,它的开发者包括许多个人和公司团体,充分体现了sun公司所倡导的代码开放性原则.在 ...
- 【JS】JavaScript 指定日期增加天数
指定某个日期(字符串),增加n天后,输出日期字符串,格式:年-月-日: /** * [dateAddDays 从某个日期增加n天后的日期] * @param {[string]} dateStr [日 ...
- 网站分析平台:是选择百度统计,还是 Google Analytics 呢?
当你拥有个人博客或个人网站时,你一定需要一个平台来分析你的网站状况.之前我在法国只是使用 Google Analytics,后来回国发现这个平台在国内受限制了,于是我找到了百度统计,目前我同时使用这两 ...
- P5283 [十二省联考2019]异或粽子
考场上想到了没打完,细节思路还是不是很优,我原先的想法是每一次找完后标记那个点,下次再继续找(并不是这个意思,说不清楚)但实际上和平衡树一样加个大小就很好写了 #include<bits/std ...
- 简单的Web日志处理细节
- jsp网页连接mysql数据库
1.在mysql数据库中建立数据表 建一张测试表test,插入几条数据: 2.设置JDBC驱动 将 mysql-connector-java-5.0.8-bin.jar 拷到WebContent/WE ...
- Python:匿名函数lambda的函数用法和排序用法
一.介绍: Lambda函数,是一个匿名函数,创建语法: lambda parameters:express parameters:可选,如果提供,通常是逗号分隔的变量表达式形式,即位置参数. exp ...
- dialog自适应大小、固定大小、底部显示
创建一个从底部显示的对话框 if (dialog == null) { dialog = new Dialog(context, R.style.theme_from_bottom); View vi ...
- 强大的Resharp插件(转)
使用VS有段时间了,一直深深的折服于其强大的功能.之前一直听说有Resharp这个工具,小猪一直也没有太在意.直到今天…… 下载安装: http://www.jetbrains.com/resharp ...
- dos.orm的事务处理
dos.orm也包含事务处理,没有太多封装,这里有几个简单的示例代码. using (DbTrans trans = DbSession.Default.BeginTransaction()) { D ...