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整除. 思路:就是 ...
随机推荐
- POJ 2369 Permutations
傻逼图论. #include<iostream> #include<cstdio> #include<cstring> #include<algorithm& ...
- 打印Dom对象的所有属性和方法
<html> <head> <title>Test</title> <meta http-equiv="Content-Type&quo ...
- java实现的kmp算法
package DataStructure; import java.util.ArrayList; import java.util.List; //KMP算法的实现 //以下代码由freedom结 ...
- ecshop 分类树全部显示
1.在page_header.lbi文件中加入 $GLOBALS['smarty']->assign('categories',get_categories_tree()); // 保证首页页面 ...
- hadoop完全分布式模式的安装和配置
本文是将三台电脑用路由器搭建本地局域网,系统为centos6.5,已经实验验证,搭建成功. 一.设置静态IP&修改主机名&关闭防火墙(all-root)(对三台电脑都需要进行操作) 0 ...
- Android 开源项目PhotoView源码分析
https://github.com/chrisbanes/PhotoView/tree/master/library 这个就是项目地址,相信很多人都用过,我依然不去讲怎么使用.只讲他的原理和具体实现 ...
- Arduino运行时突然[卡死在某一行/立即重启/串口输出乱码/程序执行不正常]的可能原因
1.这一行是分配内存,而内存不够了(Arduino uno只有2k) 2.内存本身已经只剩一点点了,于是就有莫名其妙的问题 3.没有调用Wire.begin().xx.setup()之类的操作!
- Datawindow.net+access数据窗口制作方法
1) 数据字典:采用SQLServer桌面程序来创建数据字典.配置正确的pbl文件生成输入列表. 在SQLServers查询器中执行select * from pbcatedt where pbe_n ...
- apple-touch-icon,shortcut icon和icon的区别
apple-touch-icon 可以了解到这是一个类似网站favicon的图标文件,用来在iphone和ipod上创建快捷键时使用. 这个文件应当是png格式,57x57像素大小,放在网站根目录之下 ...
- Apache加载PHP.ini顺序
网上找到一份关于Apache加载PHP.ini顺序的文档: (1) apache的httpd.conf中的PhpIniDir: (2) 注册表键值:HKEY_LOCAL_MACHINE->SOF ...