hdoj 5373 The shortest problem
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5373
一开始想到用整除11的性质去做,即奇位数的和和偶位数的和的差为11的倍数,但估不准数据范围没敢去做,
尝试去敲大数,HFZ想出了一个比较巧的方法,模拟计算的过程,用变量去存sum,sum = sum + 各位数字之和,
如果更新后的num是11的倍数,num就可以归0了,极大简化了过程,Int范围内就可以做。代码如下:
#include<stdio.h> int get_sum(int x){ ; while(x){ sum += x%; x /= ; } return sum; } int get_lgt(int x){ ; while(x >= base){ ; } return base; } int main(){ int num; int n; int sum; int lgt; ; while(scanf("%d %d",&num,&n)){ && n == -) break; if(n){ sum = ; sum = sum+get_sum(num); num %= ; lgt = get_lgt(sum); num = num*lgt+sum; } ; i < n; ++i){ //sum一直存sum,num一直存目前的数 sum = sum+get_sum(sum); num %= ; lgt = get_lgt(sum); num = num*lgt+sum; } printf("Case #%d: ",++T); )) puts("Yes"); else puts("No"); } }
hdoj 5373 The shortest problem的更多相关文章
- 同余模定理 HDOJ 5373 The shortest problem
题目传送门 /* 题意:题目讲的很清楚:When n=123 and t=3 then we can get 123->1236->123612->12361215.要求t次操作后, ...
- hdu 5373 The shortest problem(杭电多校赛第七场)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5373 The shortest problem Time Limit: 3000/1500 MS (J ...
- 2015 Multi-University Training Contest 7 hdu 5373 The shortest problem
The shortest problem Time Limit: 3000/1500 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Oth ...
- HDU 5373 The shortest problem (数学)
题意:给定两个数的n和m,有一种操作,把 n 的各位数字加起来放到 n后面形成一个新数n,问重复 m 次所得的数能否整除 11. 析:这个题首先要知道一个规律奇数位的和减去偶数位的和能被11整除的数字 ...
- HDU-5373 The shortest problem
The shortest problem http://acm.hdu.edu.cn/showproblem.php?pid=5373 Time Limit: 3000/1500 MS (Java/O ...
- The shortest problem
The shortest problem Time Limit: 3000/1500 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others ...
- Manacher HDOJ 5371 Hotaru's problem
题目传送门 /* 题意:求形如(2 3 4) (4 3 2) (2 3 4)的最长长度,即两个重叠一半的回文串 Manacher:比赛看到这题还以为套个模板就行了,因为BC上有道类似的题,自己又学过M ...
- The shortest problem(hdu,多校
The shortest problem Time Limit: 3000/1500 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Oth ...
- HDU 5373(2015多校7)-The shortest problem(模拟%11)
题目地址:pid=5373">HDU 5373 题意:给你一个数n和操作次数t,每次操作将n的各位数之和求出来放在n的末尾形成新的n,问t次操作后得到的n能否够被11整除. 思路:就是 ...
随机推荐
- UVa11582 Colossal Fibonacci Numbers!
#include<cstdio> #include<iostream> #include<cstring> #include<algorithm> us ...
- 使用Rxjava缓存请求
最近,我尝试使用RxJava开发了一款闲时备份app.我必须承认,一旦你get到了正确的方式,RxJava几乎感觉就像作弊.一切看起来更简洁,多个请求能够被组合,且非常容易控制.通过在UI线程观察和在 ...
- 使用C#代码发起K2 Blackpearl流程
转:http://www.cnblogs.com/dannyli/archive/2011/08/02/2125285.html 使用C#代码,发起一个K2的流程,其形式和链接SQL Server数据 ...
- tomcat Manger App
转发链接,嘿嘿http://simeon.blog.51cto.com/18680/58877
- window 与ubuntu共享文件 hgfs下为空和不用每次挂载hgfs的方法
解决hgfs为空的方法: sudo apt-get install open-vm-dkms sudo mount -t vmhgfs .host:/ /mnt/hgfs 解决每次都要挂载的方法: 1 ...
- HashBiMap
HashBiMap AbstractMap类实现了Map接口定义的一些方法,而BiMap类定义了其子类需要实现的一些方法,使得所有实现BiMap的类必须符合其独有的特性:键.值都是唯一的.HashB ...
- 锁之“重量级锁”Synchronized
一.Synchronized的基本使用 Synchronized是Java中解决并发问题的一种最常用的方法,也是最简单的一种方法.Synchronized的作用主要有三个:(1)确保线程互斥的访问同步 ...
- 360网站卫士推出google字体加速方案
最近,有网友反映称谷歌官网域名google.com.谷歌香港google.com.hk都打不开, ping了一下google.com和google.com.hk两个域名的服务器情况,最后ping出来的 ...
- 【PHP】linux搭建PHP运行环境
之前在windows下写了hello world,终归是不够用啊,因为开发环境是Linux,怎么办呢~~~学习学习再学习 写在前面的话:我从百度文库的一个文章里摘出来的,原文章名称<Linux下 ...
- 程序世界系列之-struts2安全漏洞引发的安全杂谈(上)
目录: 1.讨论关于struts 安全问题. 2.黑客文化. 3.如何降低安全漏洞的出现. 4.忠告建议. 题记: 这篇文章本来很早应该和大家见面的,中间由于个人原因调整了系列文章发布时间,实属罪过. ...