• 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

    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.

    Output

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

    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

    代码如下

      1 #include<cstdio>
      2 #include<iostream>
      3 #include<cmath>
      4 #include<algorithm>
      5 using namespace std;
      6 int num[][2]={
      7 220,284,
      8 1184, 1210,
      9 2620, 2924,
     10 5020, 5564,
     11 6232 ,6368,
     12 10744 ,10856,
     13 12285 ,14595,
     14 17296 ,18416,
     15 63020 ,76084,
     16 66928 ,66992,
     17 67095 ,71145,
     18 69615 ,87633,
     19 79750 ,88730,
     20 100485 ,124155,
     21 122265 ,139815,
     22 122368 ,123152,
     23 141664 ,153176,
     24 142310 ,168730,
     25 171856 ,176336,
     26 176272 ,180848,
     27 185368 ,203432,
     28 196724 ,202444,
     29 280540 ,365084,
     30 308620 ,389924,
     31 319550 ,430402,
     32 356408 ,399592,
     33 437456 ,455344,
     34 469028 ,486178,
     35 503056 ,514736,
     36 522405, 525915,
     37 600392, 669688,
     38 609928 ,686072,
     39 624184, 691256,
     40 635624, 712216,
     41 643336, 652664,
     42 667964, 783556,
     43 726104 ,796696,
     44 802725 ,863835,
     45 879712 ,901424,
     46 898216, 980984,
     47 947835, 1125765,
     48 998104, 1043096,
     49 1077890, 1099390,
     50 1154450, 1189150,
     51 1156870 ,1292570,
     52 1175265 ,1438983,
     53 1185376, 1286744,
     54 1280565, 1340235,
     55 1328470 ,1483850,
     56 1358595 ,1486845,
     57 1392368 ,1464592,
     58 1466150,1747930,
     59 1468324,1749212,
     60 1511930, 1598470,
     61 1669910, 2062570,
     62 1798875, 1870245,
     63 2082464, 2090656,
     64 2236570 ,2429030,
     65 2652728 ,2941672,
     66 2723792 ,2874064,
     67 2728726 ,3077354,
     68 2739704, 2928136,
     69 2802416 ,2947216,
     70 2803580 ,3716164,
     71 3276856 ,3721544,
     72 3606850 ,3892670,
     73 3786904 ,4300136,
     74 3805264 ,4006736,
     75 4238984 ,4314616,
     76 4246130, 4488910,
     77 4259750 ,4445050,
     78 4482765 ,5120595,
     79 4532710 ,6135962,
     80 4604776 ,5162744
     81 
     82 };
     83 
     84 
     85 
     86 int main()
     87 {
     88     int a,b;
     89     int i;
     90     int sum;
     91     while(~scanf("%d%d",&a,&b))
     92     {
     93         sum=0;
     94         for(i=0;i<148;i++)
     95         {
     96             if(num[i][0]>=a&&num[i][1]<=b)
     97                 sum++;
     98             if(num[i][0]>b)
     99                 break;
    100         }
    101         printf("%d
    ",sum);
    102     }
    103     return 0;
    104 }
  • 相关阅读:
    msbuild.exe保持打开状态,锁定文件
    angular中使用echarts并实现数据更新
    浅谈flexible.js移动端自适应方案
    centos7 安装
    尚硅谷Java基础篇(717集)
    auto 和 decltype
    一个简单的 socket 网络编程
    项目搭建过程中初始化mysql常遇到的问题总结
    超微服务器内存不在位
    UEFI模式下修改RAID组cache方法
  • 原文地址:https://www.cnblogs.com/Annetree/p/6641303.html
Copyright © 2020-2023  润新知