poj-3286-How many 0's?
2014-01-07 18:15
302 查看
分别求出各个位置为0时懂得情况数即可
#include<string.h> #include<algorithm> #include<stdlib.h> #include<iostream> #include<stdio.h> #include<vector> #define LL long long using namespace std; LL ans(LL x) { if(x<0)return 0; LL i,ans; i=1; ans=1; LL y; int now; while(i*10<=x) { y=x/(i*10)-1; if(y<0)y=0; ans+=y*i; now=(x/i)%10; if(now==0)ans+=x%i+1; else ans+=i; i=i*10; } return ans; } int main() { LL m,n; while(~scanf("%lld%lld",&m,&n)&&(m!=-1||n!=-1)) { cout<<ans(n)-ans(m-1)<<endl; } return 0; }
相关文章推荐
- POJ 3286 How many 0's?(数位dp)
- POJ 3286 How many 0's?(数论)
- POJ 3286 How many 0's?
- Poj 3286 How many 0's? + Bzoj 1833 count 数字计数(数位统计)
- poj 3286 How many 0's? --- 数位dp
- POJ 3286- How many 0's?(组合数学_区间计数)
- poj 3286 How many 0's?
- POJ 3286 How many 0's?(数位DP)
- How many 0's? - POJ 3286 数位dp
- POJ 3286 How many 0's?
- POJ 3286 How many 0's? / 2282 The Counting Problem 排列组合统计数字
- poj 3286 How many 0's?
- POJ 3286 How many 0's? (数位dp)
- poj 3286 How many 0's? 按位统计
- poj 3286 How Many 0's?
- poj 2282 The Counting Problem & 3286 How many 0's?
- 3286 How many 0's? 计算(n,m)中有多少个0
- POJ - 3286 - How many 0's? - (统计0的个数)
- POJ - 3286 - How many 0s? 【数位DP】
- TOJ 2294 POJ 3286 How many 0's? 数位dp