NBUT 1223 Friends number 2010辽宁省赛
Time limit 1000 ms
Memory limit 131072 kB
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]。
Input
Each test case contains two positive integers a, b(1<= a <= b <=5,000,000).
Proceed to the end of file.
Output
Sample Input
1 100
1 1000
Sample Output
0
1
Hint
6 is a number whose sum of all divisors is 6. 6 is not a friend number, these number is called Perfect Number. 暴力打表找出1-5000000的friends number,打表的时候记得先开方,要不然时间会耗得很长,打表得到70+组friends number 代码如下
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
int num[][]={
,,
, ,
, ,
, ,
,,
,,
,,
,,
,,
,,
,,
,,
,,
,,
,,
,,
,,
,,
,,
,,
,,
,,
,,
,,
,,
,,
,,
,,
,,
, ,
, ,
,,
, ,
, ,
, ,
, ,
,,
,,
,,
, ,
, ,
, ,
, ,
, ,
,,
,,
, ,
, ,
,,
,,
,,
,,
,,
, ,
, ,
, ,
, ,
,,
,,
,,
,,
, ,
,,
,,
,,
,,
,,
,,
,,
, ,
,,
,,
,,
, }; int main()
{
int a,b;
int i;
int sum;
while(~scanf("%d%d",&a,&b))
{
sum=;
for(i=;i<;i++)
{
if(num[i][]>=a&&num[i][]<=b)
sum++;
if(num[i][]>b)
break;
}
printf("%d\n",sum);
}
return ;
}
NBUT 1223 Friends number 2010辽宁省赛的更多相关文章
- NBUT 1224 Happiness Hotel 2010辽宁省赛
Time limit 1000 ms Memory limit 131072 kB The life of Little A is good, and, he managed to get enoug ...
- NBUT 1222 English Game 2010辽宁省赛
Time limit 1000 ms Memory limit 131072 kB This English game is a simple English words connection gam ...
- NBUT 1221 Intermediary 2010辽宁省赛
Time limit 1000 ms Memory limit 131072 kB It is widely known that any two strangers can get to know ...
- NBUT 1225 NEW RDSP MODE I 2010辽宁省赛
Time limit 1000 ms Memory limit 131072 kB Little A has became fascinated with the game Dota recent ...
- NBUT 1220 SPY 2010辽宁省赛
Time limit 1000 ms Memory limit 131072 kB The National Intelligence Council of X Nation receives a ...
- NBUT 1218 You are my brother 2010辽宁省赛
Time limit 1000 ms Memory limit 131072 kB Little A gets to know a new friend, Little B, recently. On ...
- NBUT 1219 Time 2010辽宁省赛
Time limit 1000 ms Memory limit 131072 kB Digital clock use 4 digits to express time, each digit ...
- NBUT 1217 Dinner 2010辽宁省赛
Time limit 1000 ms Memory limit 32768 kB Little A is one member of ACM team. He had just won the g ...
- ZOJ 1985 Largest Rectangle in a Histogram(刷广告)2010辽宁省赛
Largest Rectangle in a Histogram Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 21204 ...
随机推荐
- python 删除列表中的字典元素
data={"} ,{"}]} print("before:\n\n",data,"\n\n") temp=- k= for i in da ...
- Mac OS下安装mvn
Step1: 去官网地址下载 http://maven.apache.org/download.cgi Step2: 解压并且移动到指定到目录下 Step3: 配置环境变量并使之生效 .bash_pr ...
- S4 对象系统
上一节中,我们介绍了 S3 系统.与大多数其他编程语言的面向对象系统不同,与那些类被定义为固定结构,且随着程序编译有确定的方法分派的系统相比,S3 系统显得非常不严谨.当我们定义一个 S3 类时,几乎 ...
- nginx反向代理和正向代理,优缺点
http://blog.csdn.net/lishaojun0115/article/details/53200629 nginx反向代理代理的是服务器,正向代理代理的是客户端, 反向代理是客户点发送 ...
- http和WebSocket
有关http和WebSocket 的区别网上有很多的质料. 个人在此仅仅是记录以下自己的学习心得,自己的理解. 1. http协议是用在应用层的协议,他是基于tcp协议的,http协议建立链接也必须要 ...
- nginx常用命令汇总
nginx基础命令: sudo nginx // 开启nginx服务器 sudo nginx -s reload // 重启nginx服务器 sudo nginx -s stop // 关闭nginx ...
- Python mysql-表中数据的大量插入
2017-09-06 23:28:26 import pymysql db = pymysql.connect("localhost","root"," ...
- android--------验证码倒计时
在我们注册或者修改信息的时候,常会用到60s倒计时这个功能,写了这篇文章,大家共享一下: 效果图: 直接上代码: activity.java public class MainActivity ext ...
- Confluence 6 LDAP 服务器配置
名字(Name) 输入一个有意义的 LDAP 服务器名字,会让你更好的识别你的目录服务器.例如: Example Company Staff Directory Example Company Cor ...
- zzuli2130卡时bfs题
https://acm.zzuli.edu.cn/zzuliacm/problem.php?id=2130 2130: hipercijevi Time Limit: 1 Sec Memory Li ...