HDU--4722
2013-09-15 20:55
204 查看
题目:
分析:找规律,每十个数中有一个。
View Code
Good Numbers
原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=4722分析:找规律,每十个数中有一个。
#include<iostream> #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> using namespace std; #define maxn 100005 #define LL __int64 int main() { int T,cas=1; cin>>T; LL l,r; while(T--) { scanf("%I64d%I64d",&l,&r); LL ll=l,rr=r; LL cnt1=0,cnt2=0; LL m1=l%10,m2=r%10; LL tmp1=l/10,tmp2=r/10; LL t1=(l-m1-1)/10,t2=(r-m2-1)/10; if(l==m1)t1=-1; if(r==m2)t2=-1; t1++,t2++; while(tmp1) { cnt1+=tmp1%10; tmp1/=10; } while(tmp2) { cnt2+=tmp2%10; tmp2/=10; } for(LL i=0;i<=m1;i++) { if((cnt1+i)%10==0)t1++; } for(LL i=0;i<=m2;i++) { if((cnt2+i)%10==0)t2++; } LL cnt=0; while(l) { cnt+=l%10; l/=10; } if(cnt%10==0)t2++;a printf("Case #%d: %I64d\n",cas++,t2-t1); } return 0; }
View Code
相关文章推荐
- hdu3652 && hdu 4722 && hdu3555
- hdu 4722 Good Numbers(找规律,记忆化搜索,数位dp)
- HDU 4722 Good Numbers
- HDU 4722 Good Numbers
- HDU 4722 Good Numbers
- HDU4722~Good Numbers(思路)
- HDU-4722-Good Numbers(找规律)
- HDU 4722:Good Numbers(数位DP)
- HDU 4722 Good Numbers(找规律)
- 【HDU 4722】Good Numbers
- hdu 4722 Good Numbers 数位dp(2013 ACM/ICPC Asia Regional Online —— Warmup2 1007)
- HDU-4722 Good Numbers 数位DP
- hdu 4722 Good Numbers(初涉数位dp)
- HDU 4722 Good Numbers (数位dp)
- HDU 4722 Good Numbers(数位DP)
- hdu 4722(记忆化搜索)
- HDU 4722 (数位DP 水~)
- hdu 4722 Good Numbers 数位dp
- hdu 4722 Good Numbers(规律题)
- hdu 4722(记忆化搜索)