HDU 4722 Good Numbers
来源:互联网 发布:ubuntu解压缩命令 编辑:程序博客网 时间:2024/04/30 21:32
If we sum up every digit of a number and the result can be exactly divided by 10, we say this number is a good number.
You are required to count the number of good numbers in the range from A to B, inclusive.
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).
21 101 20
Case #1: 0Case #2: 1
The answer maybe very large, we recommend you to use long long instead of int. 可以数位dp,不过其实直接找规律就可以了,打个表可以看出来,我取了100作为结果,当然取10更好。#include<map> #include<set> #include<ctime> #include<cmath> #include<stack>#include<queue> #include<string> #include<vector> #include<cstdio> #include<cstring> #include<iostream> #include<algorithm> #include<functional> using namespace std;#define ms(x,y) memset(x,y,sizeof(x)) #define rep(i,j,k) for(int i=j;i<=k;i++) #define per(i,j,k) for(int i=j;i>=k;i--) #define loop(i,j,k) for (int i=j;i!=-1;i=k[i]) #define inone(x) scanf("%d",&x) #define intwo(x,y) scanf("%d%d",&x,&y) #define inthr(x,y,z) scanf("%d%d%d",&x,&y,&z) #define infou(x,y,z,p) scanf("%d%d%d%d",&x,&y,&z,&p) #define lson x<<1,l,mid #define rson x<<1|1,mid+1,r #define mp(i,j) make_pair(i,j) #define ff first #define ss second typedef long long LL;typedef pair<int, int> pii;const int low(int x) { return x&-x; }const int INF = 0x7FFFFFFF;const int mod = 1e9 + 7;const int N = 1e5 + 10;const double eps = 1e-10;int T, cas = 1;LL n, m;LL calc(LL x){if (x < 0) return 0;LL y = x / 100 * 100, z = 0;for (; y <= x; y++){int sum = 0;for (LL i = y; i; i /= 10) sum += i % 10;if (sum % 10) continue;z++;}return x / 100 * 10 + z;}int main(){for (inone(T); T--; cas++){scanf("%lld%lld", &n, &m);printf("Case #%d: %lld\n", cas, calc(m) - calc(n - 1));}return 0;}
0 0
- HDU 4722 Good Numbers
- HDU 4722 Good Numbers
- Hdu 4722 Good Numbers
- hdu 4722 Good Numbers
- HDU 4722 Good Numbers
- HDU 4722 Good Numbers
- hdu 4722 Good Numbers
- HDU 4722 Good Numbers
- HDU 4722 Good Numbers
- HDU 4722-Good Numbers
- HDU 4722 Good Numbers
- hdu 4722 Good Numbers
- HDU 4722 Good Numbers
- hdu 4722 good numbers
- 【HDU】 4722 Good Numbers
- HDU 4722 Good Numbers
- hdu 4722 Good Numbers
- hdu 4722 Good Numbers(dp)
- 算法训练 比较字符串
- 二分——POJ 3579 Median
- ComboBox 控件 CheckedListBox 控件 PictureBox 控件的使用 Timer 控件
- ComboBox 控件 CheckedListBox 控件 PictureBox 控件的使用 Timer 控件
- Top 100论文导读:深度神经网络的理解,泛化以及迁移学习
- HDU 4722 Good Numbers
- 计算长方体、四棱锥的表面积和体积
- 好听的英文歌曲收录
- (对象流)ObjectInputStreamAndOut
- Linux中的task_struct结构体
- ubuntu14.04安装tomcat8
- [LeetCode]208. Implement Trie (Prefix Tree)
- BeginPaint/EndPaint(CPaintDC)与GetDC(CClientDC)的区别
- 平均周转时间各种算法