hdu-2683 TCE-frep number system---完全数+二项展开式
题目链接:
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---完全数+二项展开式的更多相关文章
- HDU 6093 - Rikka with Number | 2017 Multi-University Training Contest 5
JAVA+大数搞了一遍- - 不是很麻烦- - /* HDU 6093 - Rikka with Number [ 进制转换,康托展开,大数 ] | 2017 Multi-University Tra ...
- 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 ...
- Moduli number system
A number system with moduli is defined by a vector of k moduli, [m1,m2, ···,mk]. The moduli must be p ...
- 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 ...
- The Stern-Brocot Number System(排序二进制)
The Stern-Brocot Number System Input: standard input Output: standard output The Stern-Brocot tree i ...
- 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 ...
- 为什么实数系里不存在最小正数?(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 ...
- HDU.1394 Minimum Inversion Number (线段树 单点更新 区间求和 逆序对)
HDU.1394 Minimum Inversion Number (线段树 单点更新 区间求和 逆序对) 题意分析 给出n个数的序列,a1,a2,a3--an,ai∈[0,n-1],求环序列中逆序对 ...
- hdu 6216 A Cubic number and A Cubic Number【数学题】
hdu 6216 A Cubic number and A Cubic Number[数学] 题意:判断一个素数是否是两个立方数之差,就是验差分.. 题解:只有相邻两立方数之差才可能,,因为x^3-y ...
- POJ1023 The Fun Number System
题目来源:http://poj.org/problem?id=1023 题目大意: 有一种有趣的数字系统.类似于我们熟知的二进制,区别是每一位的权重有正有负.(低位至高位编号0->k,第i位的权 ...
随机推荐
- mysql进阶(四)mysql中select
mysql中select * for update 注: FOR UPDATE 仅适用于InnoDB,且必须在事务区块(BEGIN/COMMIT)中才能生效. 作用 锁定该语句所选择到的对象.防止在 ...
- Dynamics CRM2011 隐藏sub-grid 新建项和添加现有项按钮
在CRM2011中ribbon区的自定义按钮可以通过工具例如RibbonEditor或者RibbonWorkbench进行配置包括action.display等等,但是系统级别的按钮是不能进行编辑的, ...
- 《java入门第一季》之类(Scanner类)
/* * Scanner:用于接收键盘录入数据. * * 前面的时候: * A:导包 * B:创建对象 * C:调用方法 * * System类下有一个静态的字段: * public static f ...
- Cocos2D v2.0至v3.x简洁转换指南(五)
资源管理 如果你没有计划用SpriteBuilder,你可以继续使用后缀去管理各种不同解决方案中的图像. 首先,你需要在AppDelegate.m中将[CCBReader configrueCCFil ...
- STL - stack(栈)
Stack简介 stack是堆栈容器,是一种"先进后出"的容器. stack是简单地装饰deque容器而成为另外的一种容器. #include <stack> stac ...
- Linux下进程通信之管道
每个进程各自有不同的用户地址空间,任何一个进程的全局变量在另一个进程中都看不到,所以进程之间要交换数据必须通过内核,在内核中开辟一块缓冲区,进程1把数据从用户空间拷到内核缓冲区,进程2再从内核缓冲区把 ...
- 销售订单-修改量-高级定价关联sql
修改量消耗明细 --修改量消耗明细 SELECT t.name, t.comments, t.version_no, cux_rebate_pub.get_hou_name(p_organizatio ...
- XMPP系列(二)----用户注册和用户登录功能
1.创建一个新工程 2.导入XMPP框架 最新的XMPP框架下载地址:https://github.com/robbiehanson/XMPPFramework 将XMPP的几个文件夹拖进工程中,需要 ...
- 【45】java的封装剖析
类是构造对象的模板或蓝图. 封装的一些概念 从形式上看,封装不过是将数据和行为组合到一个包中,并对对象的使用者隐藏了数据的实现形式. 每个对象都包含实例域和方法.实例域的集合代表了一个集合的状态,通过 ...
- ActiveMQ 入门
1.下载ActiveMQ 去官方网站下载:http://activemq.apache.org/ 2.运行ActiveMQ 解压缩apache-activemq-5.5.1-bin.zip,然后双击a ...