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内约数和为偶数的数的个数. 思路:一个数 ...
随机推荐
- 使用printf函数实现串口信息打印——设置IAR和Keil的Options
在Keil和IAR中都可以使用printf函数,但两者设置的方法不一样.以下分别是IAR和Keil的设置. 下面是Keil的设置. 选中Options--->Target--->Code ...
- Java 发送短信
这是一个调用sms接口发短信的程序,支持同时发送的短信量并不是很大,只作为学习使用(当然如果你想内部使用也行) 源码:package com; import org.apache.commons.ht ...
- php循环跳出
PHP中的循环结构大致有for循环,while循环,do{} while 循环以及foreach循环几种,不管哪种循环中,在PHP中跳出循环大致有这么几种方式: 代码: <?php $i = 1 ...
- kafka与zookeeper实战笔记
kafka命令 1.先启动zookeeper zkServer.cmd/zkServer.sh2.启动kafka[需要指定server.properties文件] kafka-server-start ...
- idea新建文件无法识别(二)
1,出现问题的步骤: 当想新增一个Hello.java文件时候 选错了文件类型.新建了一个text文件.当回过头来把文件后缀改掉的时候发现idea无法识别,颜色一直是灰色. 2,解决问题的办法: 选择 ...
- Spring Boot (6) Spring Data JPA
JPA 全称Java Persistence API,JPA通过JDK 5.0注解或xml描述对象-关系表的映射关系,并将运行期的实体对象持久化到数据库中 JPA是sun官方提出的java持久化规范, ...
- sql学习--update
两种修改形式 第一种:静态插入 ,notes='began career selling ...balabala' where jc='johnny ca' 第二种: --注意别名和on后边的表连接不 ...
- JavaScript中字符串运算符的使用
字符串运算符是用于两个字符串型数据之间的运算符,它的作用是将两个字符串连接起来.在JavaScript中,可以使用+和+=运算符对两个字符串进行连接运算.其中,+运算符用于连接两个字符串,而+=运算符 ...
- ListView使用、ListView优化和遇到的问题
1.先写遇到的问题: a.ListView只显示一个item. listview只显示一个item,并且做了listview的点击事件监听打印 Bean 对象的属性和哈希值,发现只有显示的那个 Bea ...
- WEB笔记-2 剖析CSS规则
2.1 剖析CSS规则 规则即指令,其声明了需要修改的元素及要应用给元素的样式. 2.2 为文档添加样式的三种方法 行内样式:直接写在HTML文档标签中的style属性当中,行内元素只 ...