题目地址:

pid=5373">HDU 5373

题意:给你一个数n和操作次数t,每次操作将n的各位数之和求出来放在n的末尾形成新的n,问t次操作后得到的n能否够被11整除。

思路:就是简单的模拟一下乱搞。额,对于%11有一个性质,当一个数的奇数位之和与偶数位之和的差的绝对值能被11整除,那么该数就能够被11整除

#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <map>
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
typedef __int64 LL;
const int inf=0x3f3f3f3f;
const double pi= acos(-1.0);
const double esp=1e-7;
const int maxn=2*1e6+10;
LL k;
LL tail;
LL get(LL x)
{
LL cnt=1;
LL y=x;
while(x){
tail+=x%10;
x/=10;
cnt*=10;
}
k=(k*cnt+y)%11;
}
int main()
{
LL n,t;
int icase=1;
while(~scanf("%lld %lld",&n,&t)){
if(n==-1&&t==-1) break;
k=0,tail=0;
get(n);
while(t--)
get(tail);
if(!k) printf("Case #%d: Yes\n",icase++);
else printf("Case #%d: No\n",icase++);
}
return 0;
}

最新文章

  1. JavaScript鼠标经过图片的放大镜效果
  2. git 中关于LF 和 CRLF 的问题
  3. WWDC 2013 Session笔记 - UIKit Dynamics入门
  4. 图片上传iOS
  5. Apache httpd.conf的翻译
  6. js秒数转换时分秒方法
  7. lambda 3
  8. 理解 Git
  9. python中Django 使用方法简述
  10. Pyhon之Django中的Form组件
  11. 计算机组装:台式机更换CPU
  12. 《11招玩转网络安全》之第五招:DVWA命令注入
  13. go关键字之type用法
  14. 《DSP using MATLAB》Problem 7.3
  15. &lt;target&gt;.ID 和 &lt;source&gt;.ID 的属性冲突: DataType 属性不匹配
  16. AbelSu玩Kotlin
  17. css基础 -文本溢出 text-overflow:ellipsis;
  18. ios开发之--VC的生命周期
  19. Microsoft 数据访问组件 (MDAC) 的版本历史记录
  20. Spring Boot 应用系列 5 -- Spring Boot 2 整合logback

热门文章

  1. 待解决问题 oc
  2. Linux一些简单命令
  3. 【codeforces 496E】Distributing Parts
  4. PNG文件结构分析
  5. 锐捷SNMp注意:
  6. datatable 前台和后台数据格式
  7. 【iOS开发-47】怎样下载iOS 7.1 Simulator 以及iOS 8离线的Documentation这些文件?
  8. 用java实现螺旋数组
  9. wireshark界面调整成英文的
  10. pandas dataframe 做机器学习训练数据=》直接使用iloc或者as_matrix即可