http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=4757

这个题目可以用一个最笨的方法做出来,由题意可知y的数量不会很多,即可穷举,我们可以根据已列举的数字猜测y的位数t与y的关系为(10^t)mody=0

#include<stdio.h>
long long A[100]={
1,2,5,10,20,25,50,100,125,200,250,500,1000,
1250,2000,2500,5000,10000,12500,20000,25000,50000,100000,
125000,200000,250000,500000,1000000,1250000,2000000,2500000,5000000,10000000,
12500000,20000000,25000000,50000000,100000000,
125000000,200000000,250000000,500000000,1000000000ll,
1250000000ll,2000000000ll,2500000000ll,5000000000ll,50000000000ll
};
int main(){
	int a,b;
	while ( scanf("%d%d",&a,&b)!=EOF ){
		int ans=0;
		for ( int i=0;i<=60;i++ ){
			if ( A[i]>=a&&A[i]<=b ) ans++;
			else if ( A[i]>b ) break;
		}
		printf("%d\n",ans);
	}
	return 0;
}

发表评论

电子邮件地址不会被公开。

Post Navigation