The shortest problem(hdu5373+11的倍数)
2015-08-11 23:12
281 查看
The shortest problem
Time Limit: 3000/1500 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 503 Accepted Submission(s): 257
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.
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
Sample Output
Case #1: Yes Case #2: No
Source
2015 Multi-University Training Contest 7
##1005. The shortest problem
本场最水的题,被11整除的性质是奇偶位的和之差能被11整除,然后模拟一下就好了。 然后如果用longlong的话可能会T(写的好就不会),用int就好了。(经过测试用int时间为longlong的1/4)
转载请注明出处:寻找&星空の孩子
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5373
#include <iostream> #include <cstdio> #include <cstring> #include <stack> #include <queue> #include <map> #include <set> #include <vector> #include <cmath> #include <algorithm> using namespace std; #define ll long long const double eps = 1e-6; const double pi = acos(-1.0); const int INF = 0x3f3f3f3f; const int MOD = 1000000007; int n,t; int x,y,k; int main () { int a,b,c,d,e,ii=1; while (scanf ("%d%d",&n,&t)==2) { if (n==-1&&t==-1) break; a = n/10000; b = (n/1000)%10; c = (n/100)%10; d = (n/10)%10; e = n%10; //if (d!=0){k++; if(c!=0)k++; if(b!=0)k++; if(a!=0)k++;} y = d+b; x = c+a+e; while (t--) { k = 0; int p=0,q=0,m=x+y; while (m) { k++; if (k%2) p += m%10; else q += m%10; m /= 10; } //cout<<p<<" "<<q<<endl;cout<<x<<" "<<y<<endl; if (k%2) { x += q; y += p; swap(x, y); } else { x += p; y += q; } } if ((x-y)%11) printf ("Case #%d: No\n",ii++); else printf ("Case #%d: Yes\n",ii++); } return 0; }
相关文章推荐
- zoj 2334 分类: zoj templates 2015-08-11 23:12 2人阅读 评论(0) 收藏
- C++与C#互调dll的实现步骤
- 归档告警频繁监控脚本
- ViewPager
- 我的前端学习笔记 box-sizing,calc,回调函数
- Java小游戏之打飞机(二)
- C++嵌入Python语言(一):环境搭建及HelloWord程序测试
- 第一百三十一天 how can I 坚持
- IOS 30多个iOS常用动画,带详细注释
- BZOJ 1877: [SDOI2009]晨跑( 最小费用最大流 )
- Maven Web项目构建
- FragmentTabHost
- 通过顶点颜色,制作高级贴图混合效果····
- HDU 1863 畅通工程
- 用条件变量来解决生产者消费者问题
- scala的list源码解密
- jQuery版感应鼠标显示隐藏的菜单
- Linux学习笔记:常用命令总结
- Android解惑 - 为什么要用Fragment.setArguments(Bundle bundle)来传递参数(转)
- eclipse启动Tomcat服务输入http://localhost:8080/报404解决方法