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 ...
随机推荐
- Maven java.lang.OutOfMemeoryError 问题
设置MAVEN_OPTS环境变量的值为:-Xms128m -Xmx512m Java默认的最大可用内存往往不能够满足Maven运行的需要 比如在项目较大时,使用Maven生成项目站点需要占用大量的内存 ...
- shell printf
printf 可以格式化字符串,还可以制定字符串的宽度.左右对齐方式等.默认 printf 不会像 echo 自动添加换行符,我们可以手动添加 \n. 例子: $ echo "Hello, ...
- testNG 学习笔记 Day 3 常用的断言
TestNG中最常用的一个断言类是Assert.java,里面有多个静态方法,这个类我们习惯叫硬断言.对应的还有一个软断言的类,叫SoftAssert.java,这个类是需要创建实例对象,才能调用相关 ...
- angular5 路由传参的几种方式
此处介绍三种方式 方式一: 问号后面带的参数, 例如:/product?id=1&name=iphone还可以是: [routerLink]="['/books']" [q ...
- HTML中常见的其它标签
HTML中常见的其它标签 一.头标签部分 1.<title>:指定浏览器的标题栏显示的内容. 2.<base>: href 属性:指定网页中所有的超链接的目录.可以是本地目录, ...
- Linux后台日志定时清理脚本
一. 简介 linux是一个很能自动产生文件的系统,日志.邮件.备份等.虽然现在硬盘廉价,我们可以有很多硬盘空间供这些文件浪费,让系统定时清理一些不需要的文件很有一种爽快的事情.不用你去每天惦记着是否 ...
- javascript之构造函数的继承(引用网络)
这个系列的第一部分,主要介绍了如何"封装"数据和方法,以及如何从原型对象生成实例. 今天要介绍的是,对象之间的"继承"的五种方法. 比如,现在有一个" ...
- Python Install for windows X64
download python 3.7.2 for windows, https://www.python.org/ run python-3.7.2.exe
- spring boot 基础篇 -- 自带图片服务器
我们平时在日常项目中经常会遇到图片的上传和访问的情景,平时我们可能习惯于把图片传到resource或者项项目中的某个位置,这样会有一个缺点,当我们重新项目打包时,这些图片会丢失.为了解决这一缺点,我们 ...
- JS-图片控制-动画管理模块
animateManage.js ;(function(window,document,undefined){ var _aniQueue = [], //动画队列 --- ani:动画,Queue: ...