NBUT1223-Friends number
来源:互联网 发布:游戏王gx结局知乎 编辑:程序博客网 时间:2024/06/07 11:50
Friends number
- 时间限制: 1000 ms 内存限制: 131072 K
- 问题描述
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 <=5,000,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 1001 1000
- 样例输出
01
- 提示
6 is a number whose sum of all divisors is 6. 6 is not a friend number, these number is called Perfect Number.
- 来源
辽宁省赛2010
题意:若一个数的除它自己以外的所有因子和为sum,且sum除它自己以外的所有因子和为这个数,那么这对数是友好的,问【x,y】中有几对这样的数
解题思路:打表打出所有这样的数,然后暴力查找
#include <iostream>#include <cstdio>#include <cstring>#include <string>#include <map>#include <set>#include <vector>#include <algorithm>#include <cmath>#include <queue>#include <stack>#include <functional>#include <climits>using namespace std;#define LL long longconst int INF=0x3f3f3f3f;int a[100]={220,1184,2620,5020,6232,10744,12285,17296,63020,66928,67095,69615,79750,100485,122265,122368,141664,142310,171856,176272,185368,196724,280540,308620,319550,356408,437456,469028,503056,522405,600392,609928,624184,635624,643336,667964,726104,802725,879712,898216,947835,998104,1077890,1154450,1156870,1175265,1185376,1280565,1328470,1358595,1392368,1466150,1468324,1511930,1669910,1798875,2082464,2236570,2652728,2723792,2728726,2739704,2802416,2803580,3276856,3606850,3786904,3805264,4238984,4246130,4259750,4482765,4532710,4604776};int b[100]={284,1210,2924,5564,6368,10856,14595,18416,76084,66992,71145,87633,88730,124155,139815,123152,153176,168730,176336,180848,203432,202444,365084,389924,430402,399592,455344,486178,514736,525915,669688,686072,691256,712216,652664,783556,796696,863835,901424,980984,1125765,1043096,1099390,1189150,1292570,1438983,1286744,1340235,1483850,1486845,1464592,1747930,1749212,1598470,2062570,1870245,2090656,2429030,2941672,2874064,3077354,2928136,2947216,3716164,3721544,3892670,4300136,4006736,4314616,4488910,4445050,5120595,6135962,5162744};int main(){ int x,y; while(~scanf("%d%d",&x,&y)) { int cnt=0; for(int i=0;i<74;i++) { if(a[i]>=x&&b[i]<=y) cnt++; } printf("%d\n",cnt); } return 0;}
- NBUT1223-Friends number
- NBUT1223 Friends number(打表,暴力)
- Friends number
- Friends number
- nyoj 411-Friends number
- nyoj 411 Friends number
- NBUT 1223 Friends number
- NBUT 1223 Friends number
- NBUT 1223 Friends number
- NBUT [1223] Friends number
- Friends number NBUT
- Friends number NBUT
- NEU 1008 Friends number
- Friends number 数论 打表
- nefu 681 Friends number 神打表。。。。
- Friends number 2010辽宁省赛
- NEU 1008 Friends number 数论 打表
- NYOJ 411 Friends number (数论--因子和)
- 文章标题
- TOJ 4483: Common Digit Pairs
- 学习淘淘商城第十六课(展示后台管理页面)
- 初识嵌入式
- Java中垃圾回收机制
- NBUT1223-Friends number
- Mac上安装MyEclipse2015 Mac破解版下载
- 朝鲜战争中的牺牲者
- rabbitMq使用笔记一:Window下安装使用RabbitMQ
- zstu4274-约素
- 广东工业大学第12届ACM程序设计大赛 Problem C: 爬楼梯
- 前端跨域问题
- 【C#项目实战】将EXCEl表格导入DataSet
- 16_struts2_1请求参数获取和校验