NBUT 1223 Friends number
来源:互联网 发布:沙漠之鹰数据图 编辑:程序博客网 时间:2024/06/10 08:42
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 1001 1000
Sample Output
01
Hint
6 is a number whose sum of all divisors is 6. 6 is not a friend number, these number is called Perfect Number.
输出所有约数和==别外一个数 别外一个数的约数和等于自己的对数 答案说到500W 结果只要50W就水过去了
/*#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>#include <cstdlib>using namespace std;int a[5000005];int main(){int i,j;memset(a,0,sizeof a);for(i=1;i<=500000;i++){for(j=1;i*j<=500000;j++){a[i*j]+=i;}}for(i=1;i<=500000;i++)a[i]-=i;int k=0;for(i=1;i<=500000;i++){if(i==a[a[i]] && i!=a[i]){if(i>a[i])continue;printf("%d,",a[i]);k++;}}return 0;}*/#include <stdio.h>int a[]={220,284,1184,1210,2620,2924,5020,5564,6232,6368,10744,10856,12285,14595,17296,18416,63020,76084,66928,66992,67095,71145,69615,87633,79750,88730,100485,124155,122265,139815,122368,123152,141664,153176,142310,168730,171856,176336,176272,180848,185368,203432,196724,202444,280540,365084,308620,389924,319550,430402,356408,399592,437456,455344,469028,486178};int main(){ int c,d; while(~scanf("%d %d",&c,&d)) { int ans=0; for(int i=0;i<56;i+=2) { if(c<=a[i] && a[i+1]<=d) ans++; } printf("%d\n",ans); } return 0;}
- NBUT 1223 Friends number
- NBUT 1223 Friends number
- NBUT 1223 Friends number
- NBUT [1223] Friends number
- NBUT 1223 Friends number(打表)
- Friends number NBUT
- Friends number NBUT
- nbut [1223] Friends number 好题,打表法的求每个数的因子和
- Friends number
- Friends number
- NBUT [1464] Biggest Number dfs
- nyoj 411-Friends number
- nyoj 411 Friends number
- NBUT1223-Friends number
- NEU 1008 Friends number
- Friends number 数论 打表
- nefu 681 Friends number 神打表。。。。
- Friends number 2010辽宁省赛
- IOS--UIButton的使用方法详细
- 在字符串中找子串
- IOS--UIAlertView的使用方法详细
- hdu 4289 Control【最小割+拆点】
- 浙江大学PAT_甲级_1062. Talent and Virtue (25)
- NBUT 1223 Friends number
- IOS--UITextFiled的使用方法详细
- uvalive5090(三维凸包)
- Xcode常用快捷键
- Android Studio 快捷键
- UISegmentControl的使用
- Java性能优化(10):谨慎改写clone
- OK6410裸机开发之Ubuntu上Openocd环境搭建
- android studio导入项目出现Gradle DSL method not found: ‘android()’