The Euler function

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)

Problem Description
The Euler function phi is an important kind of function in number theory, (n) represents the amount of the numbers which are smaller than n and coprime to n, and this function has a lot of beautiful characteristics. Here comes a very easy question: suppose you are given a, b, try to calculate (a)+ (a+1)+....+ (b)
 
Input
There are several test cases. Each line has two integers a, b (2<a<b<3000000).
 
Output
Output the result of (a)+ (a+1)+....+ (b)
 
Sample Input
3 100
 
Sample Output
3042
 
Source
思路:欧拉函数打表;
#include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
#include<queue>
#include<algorithm>
#include<stack>
#include<cstring>
#include<vector>
#include<list>
#include<set>
#include<map>
using namespace std;
#define ll __int64
#define mod 1000000007
#define inf 999999999
//#pragma comment(linker, "/STACK:102400000,102400000")
int scan()
{
int res = , ch ;
while( !( ( ch = getchar() ) >= '' && ch <= '' ) )
{
if( ch == EOF ) return << ;
}
res = ch - '' ;
while( ( ch = getchar() ) >= '' && ch <= '' )
res = res * + ( ch - '' ) ;
return res ;
}
int p[],N=;
void phi()
{
for(int i=; i<N; i++) p[i] = i;
for(int i=; i<N; i+=) p[i] >>= ;
for(int i=; i<N; i+=)
{
if(p[i] == i)
{
for(int j=i; j<N; j+=i)
p[j] = p[j] - p[j] / i;
}
}
}
int main()
{
int x,y,z,i,t;
phi();
while(~scanf("%d%d",&x,&y))
{
ll ans=;
for(i=x;i<=y;i++)
ans+=p[i];
printf("%I64d\n",ans);
}
return ;
}

hdu 2824 The Euler function 欧拉函数打表的更多相关文章

  1. hdu 2824 The Euler function(欧拉函数)

    题目链接:hdu 2824 The Euler function 题意: 让你求一段区间的欧拉函数值. 题解: 直接上板子. 推导过程: 定义:对于正整数n,φ(n)是小于或等于n的正整数中,与n互质 ...

  2. HDU - 2824 The Euler function 欧拉函数筛 模板

    HDU - 2824 题意: 求[a,b]间的欧拉函数和.这道题卡内存,只能开一个数组. 思路: ϕ(n) = n * (p-1)/p * ... 可利用线性筛法求出所有ϕ(n) . #include ...

  3. HDU 6322.Problem D. Euler Function -欧拉函数水题(假的数论题 ̄▽ ̄) (2018 Multi-University Training Contest 3 1004)

    6322.Problem D. Euler Function 题意就是找欧拉函数为合数的第n个数是什么. 欧拉函数从1到50打个表,发现规律,然后勇敢的水一下就过了. 官方题解: 代码: //1004 ...

  4. (hdu step 7.2.1)The Euler function(欧拉函数模板题——求phi[a]到phi[b]的和)

    题目: The Euler function Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Othe ...

  5. HDU 2824 The Euler function --------欧拉模板

    The Euler function Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Other ...

  6. HDU 5597 GTW likes function 欧拉函数

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5597 题意: http://bestcoder.hdu.edu.cn/contests/contes ...

  7. UVA 11426 GCD - Extreme (II)(欧拉函数打表 + 规律)

    Given the value of N, you will have to find the value of G. The definition of G is given below:Here ...

  8. A - Bi-shoe and Phi-shoe (欧拉函数打表)

    Description Bamboo Pole-vault is a massively popular sport in Xzhiland. And Master Phi-shoe is a ver ...

  9. POJ 2478 欧拉函数打表的运用

    http://poj.org/problem?id=2478 此题只是用简单的欧拉函数求每一个数的互质数的值会超时,因为要求很多数据的欧拉函数值,所以选用欧拉函数打表法. PS:因为最后得到的结果会很 ...

随机推荐

  1. (转)spring boot整合redis

    一篇写的更清晰的文章,包括redis序列化:http://makaidong.com/ncjava/330749_5285125.html 1.项目目录结构 2.引入所需jar包 <!-- Sp ...

  2. [LeetCode] questions conclusion_ Dynamic Programming

    Questions: [LeetCode] 198. House Robber _Easy tag: Dynamic Programming [LeetCode] 221. Maximal Squar ...

  3. 源代码下载 作者:王先荣(Xianrong Wang)

    作者:王先荣(Xianrong Wang) 下面是我的一些源代码: 1. 图像处理学习系列源代码——包括该系列文章的几乎所有代码: 1.5. 图像处理学习系列中用到的dll文件包——将这个解压缩之后放 ...

  4. 筛选DataTable中的数据

    DataTable dt = bll.GetTable(); //查询数据 DataTable newdt = new DataTable(); //一个新的table来保存筛选的记录 newdt = ...

  5. Oracle的FIXED_DATE参数

    今天发现一个有意思的问题, 我们知道,在Oracle数据库中正常执行 select sysdate from dual 都可以返回当前主机的系统时间. 正常修改系统时间,对应的查询结果也会变成修改后的 ...

  6. MatLab 2014a编译jar包时mcc无法使用的问题

    http://blog.csdn.net/heroafei/article/details/43273373 MatLab 2014a编译jar包时mcc无法使用的问题 2015-01-29 16:5 ...

  7. C++矩阵库 Eigen 快速入门

    最近需要用 C++ 做一些数值计算,之前一直采用Matlab 混合编程的方式处理矩阵运算,非常麻烦,直到发现了 Eigen 库,简直相见恨晚,好用哭了. Eigen 是一个基于C++模板的线性代数库, ...

  8. Description Resource Path LocationType Java compiler level does not match the version of the instal

    从别的地方导入进来的maven项目报: Description Resource Path Location TypeJava compiler level does not match the ve ...

  9. byte、二进制、十进制数值之间的转换

    项目中遇到将字节数据文件解析成可展示的十进制,经过调查和测试得出下面的转换方法 1.将byte值转换为二进制字符串: byte byteValue = -1; // 将byte转换为8位二进制字符串 ...

  10. Python2 和Python3 的差异总结

    一.基本语法差异 1.1 核心类差异 Python3对Unicode字符的原生支持 Python2中使用 ASCII 码作为默认编码方式导致string有两种类型str和unicode,Python3 ...