- #include<iostream>
- #include<cstdio>
- #include<stdlib.h>
- #include<math.h>
- #include<string.h>
- using namespace std;
- #define MAX 1000000
- int str[MAX];
- int main()
- {
- int a,b,n,tt=1,j,i;
- memset(str,0,sizeof(str));
- for(i=1; i<MAX; i++)
- {
- for(j=i+i; j<MAX; j=j+i)
- {
- str[j]+=i;//完美数和打表
- }
- }
- while(~scanf("%d%d%d",&a,&b,&n))
- {
- if(a==0&&b==0&&n==0)break;
- int k2=0;
- printf("Test %d: ",tt++);
- for(i=a;i<=b;i++)
- if(abs(str[i]-i)<=n)
- {
- k2++;
- }
- printf("%d\\n",k2);
- }
- return 0;
- }
- //该片段来自于http://www.codesnippet.cn/detail/1612201411278.html
来源: http://www.codesnippet.cn/detail/1612201411278.html