黑龙江省2010年省赛

数论题+打表题,因子和,模板打就好。


1008: Friends number

时间限制:  1 Sec   内存限制:  128 MB
提交:  360   解决:  99
[ 提交 ][ 状态 ][ 讨论版 ]

题目描述

Paula and Tai are couple. There are many stories between them. The day Paula left by airplane, Tai send one message to telephone 2200284, then, everything is changing… (The story in “the snow queen”).

After a long time, Tai tells Paula, the number 220 and 284 is a couple of friends number, as they are special, all divisors of 220’s sum is 284, and all divisors of 284’s sum is 220. Can you find out there are how many couples of friends number less than 10,000. Then, how about 100,000, 200,000 and so on.

The task for you is to find out there are how many couples of friends number in given closed interval [a,b]

输入

There are several cases.

Each test case contains two positive integers a, b(1<= a <= b <=500,000).

Proceed to the end of file.

输出

For each test case, output the number of couples in the given range. The output of one test case occupied exactly one line.

样例输入

1 100
#include<cstdio>
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<cstring>
using namespace std;
int main()
{
	int a,b;
	int sum=0;
	while(scanf("%d%d",&a,&b)!=EOF)
	{
		sum=0;
		if(a<=220&&b>=284)
   			sum++;
		if(a<=1184&&b>=1210)
 			sum++;
		if(a<=2620&&b>=2924)
		   	sum++;
		if(a<=5020&&b>=5564)
		   	sum++;
		if(a<=6232&&b>=6368)
		   	sum++;
		if(a<=10744&&b>=10856)
		  	sum++;
		if(a<=12285&&b>=14595)
		   sum++;
		if(a<=17296&&b>=18416)
		   sum++;
		if(a<=63020&&b>=76084)
		   sum++;
		if(a<=66928&&b>=66992)
		   sum++;
		if(a<=67095&&b>=71145)
		   sum++;
		if(a<=69615&&b>=87633)
		   sum++;
		if(a<=79750&&b>=88730)
		   sum++;
		if(a<=100485&&b>=124155)
		   sum++;
		if(a<=122265&&b>=139815)
		   sum++;
		if(a<=122368&&b>=123152)
		   sum++;
		if(a<=141664&&b>=153176)
		   sum++;
		if(a<=142310&&b>=168730)
		   sum++;
		if(a<=171856&&b>=176336)
		   sum++;
		if(a<=176272&&b>=180848)
		   sum++;
		if(a<=185368&&b>=203432)
		   sum++;
		if(a<=196724&&b>=202444)
		   sum++;
		if(a<=280540&&b>=365084)
		   sum++;
		if(a<=308620&&b>=389924)
		   sum++;
		if(a<=319550&&b>=430402)
		   sum++;
		if(a<=356408&&b>=399592)
		   sum++;
		if(a<=437456&&b>=455344)
		   sum++;
		if(a<=469028&&b>=486178)
		   sum++;
		if(a<=503056&&b>=514736)
		   sum++;
		if(a<=522405&&b>=525915)
		   sum++;
		if(a<=600392&&b>=669688)
		   sum++;
		if(a<=609928&&b>=686072)
		   sum++;
		if(a<=624184&&b>=691256)
		   sum++;
		if(a<=635624&&b>=712216)
		   sum++;
		if(a<=643336&&b>=652664)
		   sum++;
		if(a<=667964&&b>=783556)
		   sum++;
		if(a<=726104&&b>=796696)
		   sum++;
		if(a<=802725&&b>=863835)
		   sum++;
		if(a<=879712&&b>=901424)
		   sum++;
		if(a<=898216&&b>=980984)
		   sum++;
		if(a<=947835&&b>=1125765)
		   sum++;
		if(a<=998104&&b>=1043096)
		   sum++;
		if(a<=1077890&&b>=1099390)
		   sum++;
		if(a<=1154450&&b>=1189150)
		   sum++;
		if(a<=1156870&&b>=1292570)
		   sum++;
		if(a<=1175265&&b>=1438983)
		   sum++;
		if(a<=1185376&&b>=1286744)
		   sum++;
		if(a<=1280565&&b>=1340235)
		   sum++;
		if(a<=1328470&&b>=1483850)
		   sum++;
		if(a<=1358595&&b>=1486845)
		   sum++;
		if(a<=1392368&&b>=1464592)
		   sum++;
		if(a<=1466150&&b>=1747930)
		   sum++;
		if(a<=1468324&&b>=1749212)
		   sum++;
		if(a<=1511930&&b>=1598470)
		   sum++;
		if(a<=1669910&&b>=2062570)
		   sum++;
		if(a<=1798875&&b>=1870245)
		   sum++;
		if(a<=2082464&&b>=2090656)
		   sum++;
		if(a<=2236570&&b>=2429030)
		   sum++;
		if(a<=2652728&&b>=2941672)
		   sum++;
		if(a<=2723792&&b>=2874064)
		   sum++;
		if(a<=2728726&&b>=3077354)
		   sum++;
		if(a<=2739704&&b>=2928136)
		   sum++;
		if(a<=2802416&&b>=2947216)
		   sum++;
		if(a<=2803580&&b>=3716164)
		   sum++;
		if(a<=3276856&&b>=3721544)
		   sum++;
		if(a<=3606850&&b>=3892670)
		   sum++;
		if(a<=3786904&&b>=4300136)
		   sum++;
		if(a<=3805264&&b>=4006736)
		   sum++;
		if(a<=4238984&&b>=4314616)
		   sum++;
		if(a<=4246130&&b>=4488910)
		   sum++;
		if(a<=4259750&&b>=4445050)
			sum++;

		printf("%d\n",sum);
	}
	return 0;
}

1 1000

样例输出

0
1

提示


6 is a number whose sum of all divisors is 6. 6 is not a friend number, these number is called Perfect Number.


来源

转载于:https://www.cnblogs.com/stodgers/p/3898298.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值