HDU 5373 The shortest problem(模拟)——2015 Multi-University Training Contest 7
来源:互联网 发布:淘宝店铺搬迁说明 编辑:程序博客网 时间:2024/05/20 07:32
传送门
The shortest problem
Time Limit: 3000/1500 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 2223 Accepted Submission(s): 902
Problem Description
In this problem, we should solve an interesting game. At first, we have an integer n, then we begin to make some funny change. We sum up every digit of the n, then insert it to the tail of the number n, then let the new number be the interesting number n. repeat it for t times. When n=123 and t=3 then we can get 123->1236->123612->12361215.
Input
Multiple input.
We have two integer n (0<=n<=104 ) , t(0<=t<=105 ) in each row.
When n==-1 and t==-1 mean the end of input.
We have two integer n (0<=n<=
When n==-1 and t==-1 mean the end of input.
Output
For each input , if the final number are divisible by 11, output “Yes”, else output ”No”. without quote.
Sample Input
35 2
35 1
-1 -1
题目大意:
给你一个数
整除。
解题思路:
就是按照题意进行模拟,然后需要知道的是被
和与所有偶数位上和的差能够被
组,保存每一位的值,进行判断就行了。
/**2016 - 08 - 29 下午Author: ITAKMotto:今日的我要超越昨日的我,明日的我要胜过今日的我,以创作出更好的代码为目标,不断地超越自己。**/#include <iostream>#include <cstdio>#include <cstring>#include <cstdlib>#include <cmath>#include <vector>#include <queue>#include <algorithm>#include <set>using namespace std;typedef long long LL;typedef unsigned long long ULL;const int INF = 1e9+5;const int MAXN = 1e6+5;const int MOD = 1e9+7;const double eps = 1e-7;const double PI = acos(-1);using namespace std;LL Scan_LL()///输入外挂{ LL res=0,ch,flag=0; if((ch=getchar())=='-') flag=1; else if(ch>='0'&&ch<='9') res=ch-'0'; while((ch=getchar())>='0'&&ch<='9') res=res*10+ch-'0'; return flag?-res:res;}int Scan_Int()///输入外挂{ int res=0,ch,flag=0; if((ch=getchar())=='-') flag=1; else if(ch>='0'&&ch<='9') res=ch-'0'; while((ch=getchar())>='0'&&ch<='9') res=res*10+ch-'0'; return flag?-res:res;}void Out(LL a)///输出外挂{ if(a>9) Out(a/10); putchar(a%10+'0');}int a[MAXN];int main(){ int t, cas = 1, n; while(cin>>n>>t) { if(n==-1 && t==-1) break; int tmp = n, cnt = 1, sum = 0; memset(a, 0, sizeof(a)); while(tmp) { a[cnt++] = tmp%10; sum += (tmp%10); tmp /= 10; } for(int i=1; i<=cnt/2; i++) swap(a[i], a[cnt-i]); int sum1 = 0, sum2 = 0, tp; for(int i=1; i<cnt; i++) { if(i & 1) sum1 += a[i]; else sum2 += a[i]; } ///cout<<"sum1 = "<<sum1<<endl<<"sum2 = "<<sum2<<endl; while(t--) { tmp = sum, tp = cnt; ///cout<<"sum = "<<sum<<endl; while(tmp) { a[cnt++] = tmp%10; sum += (tmp%10); tmp /= 10; } for(int i=tp; i<=(cnt-1+tp)/2; i++) swap(a[i], a[cnt-i+tp-1]); /**for(int i=1; i<cnt; i++) cout<<"a[i] = "<<a[i]<<endl; cout<<"+++++++++++++++++++++++"<<endl;*/ for(int i=tp; i<cnt; i++) { if(i & 1) sum1 += a[i]; else sum2 += a[i]; } } ///cout<<"sum1 = "<<sum1<<endl<<"sum2 = "<<sum2<<endl; if(abs(sum1-sum2) % 11 == 0) printf("Case #%d: Yes\n",cas++); else printf("Case #%d: No\n",cas++); } return 0;}
0 0
- HDU 5373 The shortest problem(模拟)——2015 Multi-University Training Contest 7
- HDU 5319 Painter(模拟 + 规律)——2015 Multi-University Training Contest 3
- HDU 5387 Clock(简单模拟)——2015 Multi-University Training Contest 8
- hdu 3571 Hotaru's problem || 2015 Multi-University Training Contest 7 (manacher算法)
- hdu 5858 Hard problem(2016 Multi-University Training Contest 10——数学题)
- hdu 5867 Water problem(2016 Multi-University Training Contest 10——水题)
- hdu 5831 Rikka with Parenthesis II(2016 Multi-University Training Contest 8——模拟)
- hdu 5328 Problem Killer 2015 Multi-University Training Contest 4
- HDU 5318 The Goddess Of The Moon(构造矩阵 )——2015 Multi-University Training Contest 3
- hdu 5783 Divide the Sequence(2016 Multi-University Training Contest 5——水题)
- hdu 5818 2016 Multi-University Training Contest 7(模拟)
- hdu-5318 The Goddess Of The Moon(2015 Multi-University Training Contest 3)
- HDU 5288 OO’s Sequence(数学)——2015 Multi-University Training Contest 1
- HDU 5399 Too Simple(数学 + 找规律)——2015 Multi-University Training Contest 9
- hdu 5813 Elegant Construction(2016 Multi-University Training Contest 7——暴力)
- hdu 5816 Hearthstone( 2016 Multi-University Training Contest 7——暴力+dfs搜索)
- 2015 Multi-University Training Contest 4 (hdu 5335、5336)模拟
- HDU HDU 3861 The King’s Problem 2011 Multi-University Training Contest 3 - Host by BIT
- 学习Java垃圾回收机制
- 【OpenCV入门教程之六】 创建Trackbar & 图像对比度、亮度值调整
- python调用shell链接mysql数据库进行操作
- Qt Label添加点击事件
- VS2015+QT5+OpenCV3开发环境搭建
- HDU 5373 The shortest problem(模拟)——2015 Multi-University Training Contest 7
- 2017网易内推笔试题---星际穿越
- 多路温度采集控制系统(3)配置文件
- Number.isInteger 兼容性
- 报错 :The method list(String, Object[]) is ambiguous for the type BaseHibernateDao<M,PK>
- java设计模式之抽象工厂模式
- android 杂七杂八
- php object
- C语言入门-第七周:作业01