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位的权 ...
随机推荐
- Oracle Inventory Management Application Program Interface ( APIs)
In this Document Goal Solution References APPLIES TO: Oracle Inventory Management - Version 12 ...
- 【Python】Shell MD5使用的那些事
MD5 应该是用的非常多的算法,就自己使用经验说说吧. 场景 算法层面不多说了,维基百科,还有很多文章都有说明. 主要用过的场景 密码存储,现在基本没怎么有使用的了,毕竟破解容易了很多 API校验,现 ...
- 停止预览时调用Camera.release(), 出现Method called after release()异常问题原因及解决办法
如下代码: private void stopPreview() { Log.w(TAG, "stopPreview(), _isPreviewing = " + _isPrevi ...
- SpriteBuilder中pivot关节中的Collide bodies属性
在SpriteBuilder中,pivot类型的关节表示两个物体围绕一个中心旋转运动的关节,也称之为pin关节. 默认情况下Collide bodies是不选的.因为在大多数情况下你不希望pivot连 ...
- 深度剖析linux内核万能--双向链表,Hash链表模版
我们都知道,链表是数据结构中用得最广泛的一种数据结构,对于数据结构,有顺序存储,数组就是一种.有链式存储,链表算一种.当然还有索引式的,散列式的,各种风格的说法,叫法层出不穷,但是万变不离其中,只要知 ...
- Android官方技术文档翻译——开发工具的构建概述
本文译自Android官方技术文档<Build Overview>,原文地址:http://tools.android.com/build. 因为<Android Lint Chec ...
- x265 (HEVC编码器,基于x264) 介绍
x265要出来了.简单翻译了一下项目网站首页的介绍. x265是一个开源项目,是一个将视频编码为h.265/高效率的视频编码(HEVC)格式的免费的库,在GNU GPL条款下发布.它的源代码是免费提供 ...
- 分布式版本库——Windows下Git的环境部署以及在GitHub上开源自己的项目
分布式版本库--Windows下Git的环境部署以及在GitHub上开源自己的项目 这几天着实忙的焦头烂额,可惜不是搞技术,今天周日,难得闲下来,写篇大家都想学习的Git教程,其实廖雪峰老师的网站已经 ...
- iOS 百度地图计算两个点时间的距离
最近在解项目bug,更新地位城市的时候有个错误,后来想在位置改变多少距离之后,再取更新位置,这个功能去年做过.但是又忘记了! 所以还是记录一下吧. 百度地图提供了一个方法: BMKMapPointFo ...
- using MR to compute PageRank
In this post I explain how to compute PageRank using the MapReduce approach to parallelization. This ...