题目链接:

http://acm.hdu.edu.cn/showproblem.php?pid=2683

题目大意:

g(n)是n的因子和

两种操作:

A a b 查询a b区间有多少个n满足上式。

Q a 查询a满不满足上式

解题思路:

上述右边二项式展开,就得到:

和上式对照,发现g(n) = 2n,由于g(n)是n的因子和,所以可以小于n的因子和就等于n

这就是完全数

而在2^63-1范围内只有8个完全数,直接打表即可

坑:给的区间不是标准的左端点 右端点形式给的,也就是A a b中a可能大于b,需要判断

#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
typedef long long ll;
ll a[] ={6LL,28LL,496LL,8128LL,33550336LL,8589869056LL,137438691328LL,2305843008139952128LL};
int main()
{
char s[];
while(cin >> s)
{
if(s[] == 'A')
{
ll x, y;
cin >> x >> y;
if(x > y)swap(x, y);//坑在这里
ll ans = ;
for(int i = ; i < ; i++)
if(a[i] >= x && a[i] <= y)ans++;
cout<<ans<<endl;
}
else if(s[] == 'Q')
{
ll x;
cin >> x;
ll flag = ;
for(int i = ; i < ; i++)
if(a[i] == x)flag = ;
cout<<flag<<endl;
}
}
return ;
}

hdu-2683 TCE-frep number system---完全数+二项展开式的更多相关文章

  1. HDU 6093 - Rikka with Number | 2017 Multi-University Training Contest 5

    JAVA+大数搞了一遍- - 不是很麻烦- - /* HDU 6093 - Rikka with Number [ 进制转换,康托展开,大数 ] | 2017 Multi-University Tra ...

  2. Find n‘th number in a number system with only 3 and 4

    这是在看geeksforgeeks时看到的一道题,挺不错的,题目是 Given a number system with only 3 and 4. Find the nth number in th ...

  3. Moduli number system

    A number system with moduli is defined by a vector of k moduli, [m1,m2, ···,mk]. The moduli must be p ...

  4. F - The Fun Number System(第二季水)

    Description In a k bit 2's complement number, where the bits are indexed from 0 to k-1, the weight o ...

  5. The Stern-Brocot Number System(排序二进制)

    The Stern-Brocot Number System Input: standard input Output: standard output The Stern-Brocot tree i ...

  6. POJ 1023 The Fun Number System

    Description In a k bit 2's complement number, where the bits are indexed from 0 to k-1, the weight o ...

  7. 为什么实数系里不存在最小正数?(Why the smallest positive real number doesn't exist in the real number system ?)

    We define the smallest positive real number as the number which is explicitly greater than zero and ...

  8. HDU.1394 Minimum Inversion Number (线段树 单点更新 区间求和 逆序对)

    HDU.1394 Minimum Inversion Number (线段树 单点更新 区间求和 逆序对) 题意分析 给出n个数的序列,a1,a2,a3--an,ai∈[0,n-1],求环序列中逆序对 ...

  9. hdu 6216 A Cubic number and A Cubic Number【数学题】

    hdu 6216 A Cubic number and A Cubic Number[数学] 题意:判断一个素数是否是两个立方数之差,就是验差分.. 题解:只有相邻两立方数之差才可能,,因为x^3-y ...

  10. POJ1023 The Fun Number System

    题目来源:http://poj.org/problem?id=1023 题目大意: 有一种有趣的数字系统.类似于我们熟知的二进制,区别是每一位的权重有正有负.(低位至高位编号0->k,第i位的权 ...

随机推荐

  1. 《java入门第一季》之面向对象(形式参数和返回值问题的深入研究3)

    /*     形式参数:         引用类型 接口:需要的是该接口的实现类对象 这个时候就没什么了,和抽象类的解释差不多. */ interface Love { public abstract ...

  2. 如何让你的传输更安全--基于SSL协议的通信模式

    之前发表在另一个平台的文章http://www.jointforce.com/jfperiodical/article/1218,现在发表到自己的博客上. 对于SSL/TLS协议,如果要每个开发者都自 ...

  3. Java学习笔记(三)Java2D组件

    一  概述 Java2D的一切都基于java.awt包中的Graphics2D类,它是Graphics的子类. 为了绘制图形,需要使用面板作为画布,例如使用JPanel作为画布,面板有一个paintC ...

  4. ANN实现

    ANN核心数据结构: typedef struct  {     int input_n;                  /* number of input units */     int h ...

  5. mtk camera 移植步骤

    mtk camera 移植步骤: 1, Kernel层驱动代码文件添加 /mediatek/custom/doov92_wet_tdd/kernel/imgsensor/下添加imx179_mipi_ ...

  6. Unix - 文件中构成一个空洞的分析

    lseek函数显示地为一个打开文件设置偏移量,文件偏移量可以大于文件的当前长度,在这种情况下,对该文件的下一次写将加长该文件,并在文件中构成一个空洞,这一点是允许的.位于文件中但没有写过的字节都被读为 ...

  7. OpenGL Shader Key Points (2)

    1.  Uniform 1.1.  Uniform变量 不是所有的变量都是跟顶点一一对应的,如变换矩阵,光源位置等. Uniform变量可以在任何类型的shader中使用,但只能作为输入值,不能在sh ...

  8. GROUP BY,WHERE,HAVING间的区别和用法

    having子句与where都是过滤语句. where 子句的作用是在对查询结果进行分组前,将不符合where条件的行去掉,即在分组之前过滤数据,条件中不能包含聚组函数,使用where条件显示特定的行 ...

  9. Linux - test测试标志的意思总结

    测试的标志 代表意义 1. 关於某个档名的『文件类型』判断,如 test -e filename 表示存在否 -e 该『档名』是否存在?(常用) -f 该『档名』是否存在且为文件(file)?(常用) ...

  10. 【Qt编程】基于Qt的词典开发系列<十三>音频播放

    在上一篇文章中,我是在Qt4平台上调用本地发音的,后来由于用到JSON解析,就将平台转到了Qt5,因为Qt5自带解析JSON的类.然后发现上一篇文章的方法无法运行,当然网上可以找到解决方法,我在这里直 ...