1445: Repeat Number

本文介绍了一个关于RepeatNumber的问题,即定义a+b=c时,若c的所有数字相同且大于10,则称a和b为RepeatNumber。文章提供了一段C语言代码,用于计算在给定区间[x,y]内有多少对这样的数。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1445: Repeat Number

Time Limit: 1 Sec   Memory Limit: 32 MB
Submit: 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


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


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);
	}
}




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值