问题 : Friends number

时间限制: 1 Sec  内存限制: 128 MB

题目描述

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 100
1 1000

样例输出

0
1

提示

6 is a number whose sum of all divisors is 6. 6 is not a friend number, these number is called Perfect Number.

解题思路

先直接暴力打表,再判断。

代码如下:

#include <stdio.h>
int s[56][2] = {
220,284,284,220,1184,1210,
1210,1184,2620,2924,
2924,2620,5020,5564,
6232,6368,6368,6232,
10744,10856,10856,10744,
12285,14595,14595,12285,
17296,18416,18416,17296,
63020,76084,66928,66992,
66992,66928,67095,71145,
69615,87633,71145,67095,
76084,63020,79750,88730,
87633,69615,88730,79750,
100485,124155,122265,139815,
122368,123152,123152,122368,
124155,100485,139815,122265,
141664,153176,142310,168730,
153176,141664,168730,142310,
171856,176336,176272,180848,
176336,171856,180848,176272,
185368,203432,196724,202444,
202444,196724,203432,185368,
280540,365084,308620,389924,
319550,430402,356408,399592,
365084,280540,389924,308620,
399592,356408,430402,319550,
437456,455344,455344,437456,
469028,486178,486178,469028};
int main()
{
    int a, b, ans;
    while(~scanf("%d%d",&a,&b))
    {
        ans = 0;
        for(int i = 0; i < 56; i++)
            if(a <= s[i][0] && s[i][0] < s[i][1] && s[i][1] <= b)
                ans++;
        printf("%d\n", ans);
    }
    return 0;
}

Friends number的更多相关文章

  1. JavaScript Math和Number对象

    目录 1. Math 对象:数学对象,提供对数据的数学计算.如:获取绝对值.向上取整等.无构造函数,无法被初始化,只提供静态属性和方法. 2. Number 对象 :Js中提供数字的对象.包含整数.浮 ...

  2. Harmonic Number(调和级数+欧拉常数)

    题意:求f(n)=1/1+1/2+1/3+1/4-1/n   (1 ≤ n ≤ 108).,精确到10-8    (原题在文末) 知识点:      调和级数(即f(n))至今没有一个完全正确的公式, ...

  3. Java 特定规则排序-LeetCode 179 Largest Number

    Given a list of non negative integers, arrange them such that they form the largest number. For exam ...

  4. Eclipse "Unable to install breakpoint due to missing line number attributes..."

    Eclipse 无法找到 该 断点,原因是编译时,字节码改变了,导致eclipse无法读取对应的行了 1.ANT编译的class Eclipse不认,因为eclipse也会编译class.怎么让它们统 ...

  5. 移除HTML5 input在type="number"时的上下小箭头

    /*移除HTML5 input在type="number"时的上下小箭头*/ input::-webkit-outer-spin-button, input::-webkit-in ...

  6. iOS---The maximum number of apps for free development profiles has been reached.

    真机调试免费App ID出现的问题The maximum number of apps for free development profiles has been reached.免费应用程序调试最 ...

  7. 有理数的稠密性(The rational points are dense on the number axis.)

    每一个实数都能用有理数去逼近到任意精确的程度,这就是有理数的稠密性.The rational points are dense on the number axis.

  8. [LeetCode] Minimum Number of Arrows to Burst Balloons 最少数量的箭引爆气球

    There are a number of spherical balloons spread in two-dimensional space. For each balloon, provided ...

  9. [LeetCode] Number of Boomerangs 回旋镖的数量

    Given n points in the plane that are all pairwise distinct, a "boomerang" is a tuple of po ...

  10. [LeetCode] Number of Segments in a String 字符串中的分段数量

    Count the number of segments in a string, where a segment is defined to be a contiguous sequence of ...

随机推荐

  1. HDFS笔记(一)

    1. HDFS 是什么? Hadoop分布式文件系统(Distributed File System)-HDFS(Hadoop Distributed File System) 2. HDFS 架构 ...

  2. Maven 传递依赖冲突解决(了解)

    1 传递依赖冲突解决(了解) 传递依赖:A(项目)依赖B,B依赖C(1.1版本),B是A的直接依赖,C就是A的传递依赖 导入依赖D,D依赖C(1.2版本) 1.1 Maven自己调解原则 1.1.1  ...

  3. 经典视觉SLAM框架

    经典视觉SLAM框架 整个视觉SLAM流程包括以下步骤: 1. 传感器信息读取.在视觉SLAM中主要为相机图像信息的读取和预处理. 2. 视觉里程计(Visual Odometry,VO).视觉里程计 ...

  4. Django实战(一)-----用户登录与注册系统3(前端页面、登录视图)

    基本框架搭建好了后,我们就要开始丰富页面内容了.最起码,得有一个用户登录的表单不是么?(注册的事情我们先放一边.) 一. 原生HTML页面 删除原来的login.html文件中的内容,写入下面的代码: ...

  5. 2017-2018-2 20165231 实验三 敏捷开发与XP实践

    实验报告封面 课程:Java程序设计 班级:1652班 姓名:王杨鸿永 学号:20165231 指导教师:娄嘉鹏 实验日期:2018年4月28日 实验时间:15:25 - 17:15 实验序号:实验三 ...

  6. Java基础4-面向对象概述;super();this()

    昨日内容回顾 java基本数据类型: byte : 一个字节,-128 ~ 127 = 256 short : 两个字节, -32768 ~ 32767 int : 四个字节, long : 八个字节 ...

  7. RabbitMQ与SpringBoot整合

    RabbitMQ  SpringBoot  一.RabbitMQ的介绍 二.Direct模式 三.Topic转发模式 四.Fanout Exchange形式 原文地址: https://www.cnb ...

  8. A Light CNN for Deep Face Representation with Noisy Labels

    承接上一篇博客.该论文思路清晰,实验充分,这里大致写一些比较不错的idea.从标题就能看出本文的主要贡献:轻量.鲁棒.利用一个轻量CNN从大规模数据且含大量噪声中来学习一个深度面部表征. 直接谈谈贡献 ...

  9. [转载]linux内存映射mmap原理分析【转】

    转自:http://www.cnblogs.com/wanpengcoder/articles/5306688.html 转自:http://blog.csdn.net/yusiguyuan/arti ...

  10. UniGUI 如何进行 UniDBGrid 的单元 Cell 的计算 ?

    来源:http://forums.unigui.com/index.php?/topic/10508-update-dataset-events-in-unidbgrid/?hl=unidbgrid ...