Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

直接求每一位上0的数字个数,然后求和

Posted by 422245257 at 2019-08-26 19:39:09 on Problem 3286
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator