Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
直接求每一位上0的数字个数,然后求和#include<cstdio> #define ll long long int using namespace std; ll m,n,ans; ll f(ll number){ ll i,j,k=0,temp=1,left=0; if(number==-1) return 0; while(number/10){ if(number%10==0) k+=(number/10-1)*temp+left+1; else k+=(number/10)*temp; left=left+temp*(number%10); temp=10*temp; number=number/10; } return k+1; } int main(){ int i,j,k; while(1){ scanf("%lld %lld",&m,&n); if(m==-1&&n==-1) break; printf("%lld\n",f(n)-f(m-1)); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator