HDU 4722 Good Numbers
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4722
Good Numbers
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 422 Accepted Submission(s): 146
You are required to count the number of good numbers in the range from A to B, inclusive.
Each test case comes with a single line with two numbers A and B (0 <= A <= B <= 1018).
- #include<cstdio>
- #include<cstring>
- #include<iostream>
- #include<algorithm>
- using namespace std;
- int keng(long long x,int left)
- {
- int n=,i,ans;
- while(x)
- {
- n+=x%;
- n%=;
- x/=;
- }
- ans=left/;
- i=-(n+ans)%;
- if(i==)
- i=;
- if(left%>=i)
- ans++;
- return ans;
- }
- bool check(long long a)
- {
- int n=;
- while(a)
- {
- n+=a%;
- n%=;
- a/=;
- }
- if(n%==)
- return true;
- else return false;
- }
- int main()
- {
- int t,i,Case,shu;
- long long a,b;
- long long Ca,Cb;
- long long left;
- scanf("%d",&t);
- // a=1;
- for(Case=;Case<=t;Case++)
- {
- // b=Case;
- scanf("%I64d%I64d",&a,&b);
- Ca=a/*;left=a%;
- Ca=keng(Ca/,left)+Ca;
- if (check(a)) Ca--;
- Cb=b/*;left=b%;
- Cb=keng(Cb/,left)+Cb;
- printf("Case #%d: %I64d\n",Case,Cb-Ca);
- }
- return ;
- }
HDU 4722 Good Numbers的更多相关文章
- 【数位DP】 HDU 4722 Good Numbers
原题直通车: HDU 4722 Good Numbers 题意: 求区间[a,b]中各位数和mod 10==0的个数. 代码: #include<iostream> #include& ...
- hdu 4722 Good Numbers(规律题)
http://acm.hdu.edu.cn/showproblem.php?pid=4722 [题意]: 找GoodNumbers一个数N,如果它每一个位数字之和可以整除10,那么它就是GoodNum ...
- HDU 4722 Good Numbers 2013年四川省赛题
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4722 题目大意:给定一个区间,求区间中有多少个满足每位上的数的和是10的倍数. 解题思路:先打表暴力求 ...
- HDU 4722 Good Numbers(位数DP)(2013 ACM/ICPC Asia Regional Online ―― Warmup2)
Description If we sum up every digit of a number and the result can be exactly divided by 10, we say ...
- hdu 4722 Good Numbers 规律 数位dp
#include<iostream> #include<cstring> #include<cstdio> #include<vector> #incl ...
- hdu 4722 Good Numbers( 数位dp入门)
Good Numbers Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Tota ...
- HDU - 4722 Good Numbers 【找规律 or 数位dp模板】
If we sum up every digit of a number and the result can be exactly divided by 10, we say this number ...
- HDU 4722 Good Numbers(DP)
题目链接 脑子有点乱,有的地方写错了,尚大婶鄙视了... 来个模版的. #include <iostream> #include <cstdio> #include <c ...
- hdu 4722 Good Numbers 数位DP
数位DP!!! 代码如下: #include<iostream> #include<stdio.h> #include<algorithm> #include< ...
随机推荐
- Uploadify 上传失败
更改Apache的php.ini的配置 In my php.ini (created custom ini file in public_html) would this solve this pro ...
- 收藏一个匹配html内容的文章
http://blog.csdn.net/donglynn/article/details/35788879
- Sass中常用的函数
字符串函数 To-upper-case() 函数将字符串小写字母转换成大写字母 To-lower-case() 函数 与 To-upper-case() 刚好相反,将字符串转换成小写字母 数字函数 S ...
- php提取背景图片
preg_match_all('/background\s*-\s*+image\s*:\s*url\s*\("*([^"]*)"*\)/i', $content,$ma ...
- lucene解决全文检索word2003,word2007的办法
在上一篇文章中 ,lucene只能全文检索word2003,无法检索2007,并且只能加载部分内容,无法加载全文内容.为解决此问题,找到了如下方法 POI 读取word (word 2003 和 wo ...
- Remark of BLENDFUNCTION from MSDN
Remarks When the AlphaFormat member is AC_SRC_ALPHA, the source bitmap must be 32 bpp. If it is not, ...
- 黑马程序员-------.net基础知识五
方法(函数) 作用:用来重复代码,当我们在一个过程中反复的写了同样的代码,一般情况下,我们就可以把需要重复写的代码定义在方法中,用的时候只需调用即可 语法: [访问修饰符][static] 返回值类型 ...
- asp.net mvc4 Controller与Action执行过程的研究(学习笔记)
当IIS收到一个http请求,把请求信息发给对应的HttpModel(实际是实现类UrlRoutingModule),在HttpModel中会注册HttpApplication 类中的PostReso ...
- 解决android模拟器太大,小屏幕无法完全显示的问题
http://hi.baidu.com/conanx/blog/item/05479befd6534d03fdfa3cbb.html 安装上Android模拟器之后,开启一个Android 2.2的模 ...
- Python的数据类型总结
原地可变类型和不可变类型 原地不可变类型又叫可哈希(hashable)类型,原地可变类型又叫不可哈希类型. 原地不可变类型: 数字类型:int, float, decimal.Decimal, fra ...