Sigma Function (找规律?)
来源:互联网 发布:淘宝退换货说明 编辑:程序博客网 时间:2024/05/19 01:07
Sigma function is an interesting function in Number Theory. It is denoted by the Greek letter Sigma (σ). This function actually denotes the sum of all divisors of a number. For example σ(24) = 1+2+3+4+6+8+12+24=60. Sigma of small numbers is easy to find but for large numbers it is very difficult to find in a straight forward way. But mathematicians have discovered a formula to find sigma. If the prime power decomposition of an integer is
Then we can write,
For some n the value of σ(n) is odd and for others it is even. Given a value n, you will have to find how many integers from 1 to n have even value of σ.
1、给的数据很大,到
2、前两题判断素数什么的都是到
3、同时也注意到素数中只有2对应的值是奇数,其它素数一定是奇数,所以对应的函数值是偶数,但是我能想到的解决方法还是暴力解决。
4、寻找答案的帮助,发现这好像是一个找规律?反正就是有式子算一下就行,这数学问题真的是。。。
5、解答:
- 首先因为偶数情况很多,我们来考虑奇数的情况好了(这个下次不能忘!我们可以从反面考虑的啊!)
- 然后把式子化为
(1+p1+p21+⋅⋅⋅+pe11)(1+p2+p22+⋅⋅⋅+pe22)⋅⋅⋅(1+pk+p2k+⋅⋅⋅+pekk)
于是只有2这个因子时一定是奇数,即2n 满足条件;
其它p 都是奇数,奇数的次方都是奇数,1也是奇数,因此对其中的一个括号,当e 是奇数时括号里的和是偶数,当e 是偶数时括号里的和是奇数。只有奇数乘奇数才会是奇数,因此里面的所有除2之外的p 对应的ei 都是偶数。 - 然后看别的做法是考虑对
n 开根号,这样得到的值也就是被开根号后还是整数的数的个数,这些数的e1⋅⋅⋅⋅ek 一定都是偶数;再对n/2 开根号,因为对因子2来说e 是偶数奇数都没有关系,这样就找到了所有对应的函数值是奇数的数的个数。 - 最后就是
n−n√−n/2−−−√
6、写完想想感觉好简单。。。然而在做题的时候就是想不到啊啊啊啊,嗯。。。果然还是要多做题(严肃脸)。还有以后做题要注意时间啊时间啊,这两天的效率是越来越低了,这样不行不行不行。
7、最后给出代码,不然感觉我的博客写的太水了= =
#include <cstdio>#include <algorithm>#include <iostream>#include <cstring>#include <queue>#include <cmath>using namespace std;long long int n, ans;int main(){ int T; while (~scanf("%d", &T)){ int t; for(t=1; t<=T; t++) { cin>>n; ans=n-int(sqrt(n))-int(sqrt(n*0.5)); //注意这里的int!!!先开始没注意又被自己坑了一次 printf("Case %d: %lld\n", t, ans); } } return 0;}
- Sigma Function (找规律?)
- 解题报告:UVA11395 Sigma Function 找规律
- LightOj 1336 Sigma Function(打表找规律)
- Uva 11395 - Sigma Function 规律 对数
- LightOJ Sigma Function 1336【打表+规律】
- 1432: [ZJOI2009]Function 找规律
- Sigma Function
- Sigma Function
- Sigma Function
- Sigma Function
- bzoj 1432: [ZJOI2009]Function (数学||找规律)
- 396.leetcode Rotate Function(easy)[找规律]
- BZOJ 1432: [ZJOI2009]Function【找规律
- BZOJ1432(ZJOI2009)[Function]题解--找规律||数论
- HDU-6156 Palindrome Function(找规律)
- HDOJ1021(找规律)
- POJ1740(找规律)
- hdu (找规律)
- Java 之Socket通信(二)
- highchart的几种数据组织形式
- 十大Intellij IDEA快捷键
- Java集合框架详解(二)——Collection源码分析
- fedora25 26系统 SecureCRT SecureFX 注册破解方法
- Sigma Function (找规律?)
- 欢迎使用CSDN-markdown编辑器
- PermGen space错误解决方法
- Visual Box 的 Host-only 连接
- 前端mvc Model和Control 要分别两个.js文件写吗?
- 着陆之后的路人甲
- hadoop伪集群配置
- python读文件read()、readline()、readlines()三个方法的区别
- hdu3068(最长回文串)