Sigma Function 数学 因子求和
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 σ.
Input
Input starts with an integer T (≤ 100), denoting the number of test cases.
Each case starts with a line containing an integer n (1 ≤ n ≤ 1012).
Output
For each case, print the case number and the result.
Sample Input
4
3
10
100
1000
Sample Output
Case 1: 1
Case 2: 5
Case 3: 83
Case 4: 947
- #include<iostream>
- #include<cstdio>
- #include<cstring>
- #include<sstream>
- #include<algorithm>
- #include<queue>
- #include<vector>
- #include<cmath>
- #include<map>
- #include<stack>
- #include<set>
- #include<fstream>
- #include<memory>
- #include<list>
- #include<string>
- using namespace std;
- typedef long long LL;
- typedef unsigned long long ULL;
- #define MAXN 1000010
- #define LLL 1000000000
- #define INF 1000000009
- /*
- 给一个公式,将一个数表示为所有素因子等比数列 求前e个 的乘积
- 求小于n的数中为奇数的个数
- 数据很大不能打表。。
- 当p为偶数 ,p的次方为偶数,加上p的0次方 最后得出奇数不成立
- 当P为奇数,P的次方为奇数,要有偶数个奇数相加才能得出偶数,要求e为奇数
- 当所有的 p和e中总是存在任何一个不为奇数的时候,结果为奇数
- e为偶数 平方数 后面乘某些数 后面的数字是2的几次方的时候仍然成立 (2是唯一的素偶数)
- 所有个数为 平方数||2*平方数
- */
- int main()
- {
- LL T,n;
- scanf("%lld", &T);
- for(LL cas=;cas<=T;cas++)
- {
- scanf("%lld", &n);
- LL t1 = sqrt(n*1.0);
- LL t2 = sqrt(n*0.5);
- printf("Case %lld: %lld\n",cas, n - t1 - t2);
- }
- return ;
- }
Sigma Function 数学 因子求和的更多相关文章
- 【LightOJ1336】Sigma Function(数论)
[LightOJ1336]Sigma Function(数论) 题面 Vjudge 求和运算是一种有趣的操作,它来源于古希腊字母σ,现在我们来求一个数字的所有因子之和.例如σ(24)=1+2+3+4+ ...
- Uva 11395 Sigma Function (因子和)
http://acm.hust.edu.cn/vjudge/contest/view.action?cid=109329#problem/C 题目在文末 题意:1~n (n:1~1012)中,因子 ...
- LightOJ1336 Sigma Function(约数和为偶数的个数)
Sigma Function Time Limit:2000MS Memory Limit:32768KB 64bit IO Format:%lld & %llu Submit ...
- LightOJ 13361336 - Sigma Function (找规律 + 唯一分解定理)
http://lightoj.com/volume_showproblem.php?problem=1336 Sigma Function Time Limit:2000MS Memory L ...
- LightOJ1336 Sigma Function —— 质因子分解、约数和为偶数
题目链接:https://vjudge.net/problem/LightOJ-1336 1336 - Sigma Function PDF (English) Statistics Forum ...
- Sigma Function (LightOJ - 1336)【简单数论】【算术基本定理】【思维】
Sigma Function (LightOJ - 1336)[简单数论][算术基本定理][思维] 标签: 入门讲座题解 数论 题目描述 Sigma function is an interestin ...
- 1336 - Sigma Function
1336 - Sigma Function PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: 32 MB S ...
- Sigma Function (平方数与平方数*2的约数和是奇数)
Sigma Function https://vjudge.net/contest/288520#problem/D Sigma function is an interesting function ...
- D - Sigma Function 1~n内有多少个约数和为偶数
/** 题目:D - Sigma Function 链接:https://vjudge.net/contest/154246#problem/D 题意:求1~n内约数和为偶数的数的个数. 思路:一个数 ...
随机推荐
- spring:使用<prop>标签为Java持久属性集注入值
spring:使用<prop>标签为Java持久属性集注入值 使用 spring 提供的<prop>为Java持久属性集注入值,也就是向 java.util.Propertie ...
- ES transport client批量导入
从bulk.txt文件中按行读取,然后bulk导入.首先通过调用client.prepareBulk()实例化一个BulkRequestBuilder对象,调用BulkRequestBuilder对象 ...
- C++ 中的友元(friend)
首先友元不是一个好的设计,它破坏了封装.并且自身有很多局限:比如友元关系不能被继承:友元关系是单向的,不具有交换性:友元关系不具有传递性. 类内声明的 friend 变量(或者函数)在访问该类的成员时 ...
- Spark常见编程问题解决办法及优化
目录 1.数据倾斜 2.TopN 3.Join优化 预排序的join cross join 考虑Join顺序 4.根据HashMap.DF等数据集进行filter 5.Join去掉重复的列 6.展开N ...
- Help Me with the Game(模拟)
http://poj.org/problem?id=2996 #include<stdio.h> #include<string.h> ][]; void find1(char ...
- SpringCloud学习 什么是微服务(一)
关于SpringCloud,我是看了周老师的<SpringCloud与Docker微服务架构实战>之后才有了一点了解,做下记录,以供后期学习.本人知识有限,如有不对,欢迎批评 1.什么是单 ...
- oj测试点相关 (整理摘编)
Accepted 通过!(AC) Wrong Answer 答案错.(WA) Runtime Error ...
- HTTPS 为什么更安全,先看这些
HTTPS 是建立在密码学基础之上的一种安全通信协议,严格来说是基于 HTTP 协议和 SSL/TLS 的组合.理解 HTTPS 之前有必要弄清楚一些密码学的相关基础概念,比如:明文.密文.密码.密钥 ...
- Android中Button四种点击事件实现方式
1.Xml添加监听属性,这里添加的doClick. <Button android:id="@+id/bt1" android:layout_width="wrap ...
- 【SQL】日期型函数
1. SYSTATE 用来返回系统当前时间 SQL> select sysdate from dual; SYSDATE ------------------- 2017-03-03 09:49 ...