1445: Repeat Number
Time Limit: 1 Sec Memory Limit: 32 MBSubmit: 194 Solved: 54
[ Submit][ Status][ Web Board]
Description
Definition: a+b = c, if all the digits of c are same ( c is more than ten),then we call a and b are Repeat Number. My question is How many Repeat Numbers in [x,y].
Input
There are several test cases.
Each test cases contains two integers x, y(1<=x<=y<=1,000,000) described above.
Proceed to the end of file.
Output
For each test output the number of couple of Repeat Number in one line.
Sample Input
1 10
10 12
Sample Output
5
2
HINT
Source
偷偷打个假表强行算了,没花多少时间#include<cstdio>
int main(){
int a,b,i,ans,x[100]={11,22,33,44,55,66,77,88,99,111,222,333,444,555,666,777,888,999,1111,2222,3333,4444,5555,6666,7777,8888,9999,11111,22222,33333,44444,55555,66666,77777,88888,99999,111111,222222,333333,444444,555555,666666,777777,888888,999999,1111111,2222222};
while(~scanf("%d%d",&a,&b)){
ans=0;
for(i=0;i<50;i++){
if(x[i]>=a*2&&x[i]<=b*2){
ans+=x[i]/2+1-((a>x[i]-b)?a:(x[i]-b));
}
}
printf("%d\n",ans);
}
}