Repeat Number

Problem B: Repeat Number

Time Limit: 1 Sec  Memory Limit: 32 MB

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

If a equals b, we can call a, b are Repeat Numbers too, and a is the Repeat Numbers for itself.

上代码

#include<stdio.h>

int a[]={
,,,,,,,,,
,,,,,,,,,
,,,,,,,,,
,,,,,,,,,
,,,,,,,,,
,,,,,,,,
}; int lower_bound(int *array, int size, int key)
{
int first = , middle;
int half, len;
len = size; while(len > ) {
half = len >> ;
middle = first + half;
if(array[middle] < key) {
first = middle + ;
len = len-half-;
}
else
len = half;
}
return first;
} int main()
{
int x,y,i,mid;
while(~scanf("%d%d",&x,&y))
{
int p=lower_bound(a,,*x);
int q=lower_bound(a,,*y);
int ans=;
if(a[q]>*y) q--;
for(i=p;i<=q;i++)
{
mid = a[i]/;
if (a[i]%==)
{
if(mid-x < y-mid)
ans+=mid-x+;
else
ans+=y-mid+;
}
else
{
if(mid-x+ < y-mid)
ans+=mid-x+;
else
ans+=y-mid;
}
}
printf("%d\n",ans);
}
return ;
}
/**************************************************************
Problem: 2
User: hui
Language: C
Result: 正确
Time:0 ms
Memory:964 kb
****************************************************************/
上一篇:hibernate笔记--组合主键映射方法


下一篇:易云盘(nester)-面对企业的和团队文档管理的平台