LightOJ 1336 Sigma Function
来源:互联网 发布:在线起名软件 编辑:程序博客网 时间:2024/05/09 05:30
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
Output for Sample Input
4
3
10
100
1000
Case 1: 1
Case 2: 5
Case 3: 83
Case 4: 947
#include<stdio.h>#include<string.h>#include<algorithm>#include<math.h>#define LL long longusing namespace std;int main(){int t,cnt=1;LL n,m,i,ans;scanf("%d",&t);while(t--){scanf("%lld",&n);ans=0;for(i=1;i*i<=n;i++){ans++;if(i*i*2<=n)ans++;}printf("Case %d: %lld\n",cnt++,n-ans);}return 0; }
- lightOJ 1336 Sigma Function
- LightOJ 1336- Sigma Function
- LightOJ 1336 Sigma Function
- LightOJ 1336 Sigma Function
- LightOj 1336(Sigma Function)
- LightOJ 1336 Sigma Function
- Sigma Function LightOJ 1336
- C - Sigma Function(LightOJ 1336)
- lightoj 1336 - Sigma Function 【数学】
- LightOJ Sigma Function 1336【打表+规律】
- LightOj 1336 Sigma Function(打表找规律)
- Sigma Function LightOJ
- Sigma Function LightOJ
- 【数学推理】Sigma Function LightOJ
- LightOJ 1336 Sigma Function(求1~n的因数和为偶数的个数)
- LightOJ 1336 Sigma Function(1--n中所有因子和为偶数的数字个数)
- Sigma Function
- Sigma Function
- Kali linux安装漏洞扫描工具Nessus安装指南
- Android性能优化总结
- 连续子数组最大和
- bss段说明
- 第十章 μC/OS-Ⅱ在80x86上的移植
- LightOJ 1336 Sigma Function
- 包装设计模式(装饰设计模式)的使用
- POJ 2421
- bzoj 1821 [JSOI2010]Group 部落划分
- C++ STL算法---unique , unique_copy函数
- 使用HTML5+CSS3+JavaScript制作网页游戏的流程
- Python学习
- 用Python建立最简单的web服务器
- 【hihocoder】#1366 : 逆序单词