http://acm.hdu.edu.cn/showproblem.php?pid=2824

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 7752    Accepted Submission(s): 3217

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 <algorithm>
#include <cstdio> using namespace std; #define LL long long
const int N();
LL a,b,phi[N]; void All_phi()
{
for(int i=;i<=N;i++)
phi[i]=i;
for(int i=;i<=N;i++)
if(phi[i]==i)
for(int j=i;j<=N;j+=i)
phi[j]=phi[j]/i*(i-);
} int main()
{
All_phi();
for(int i=;i<=N+;i++) phi[i]=phi[i-]+phi[i];
for(;scanf("%d%d",&a,&b)!=EOF;)
printf("%I64d\n",phi[b]-phi[a-]);
return ;
}

HDU——T 2824 The Euler function的更多相关文章

  1. 欧拉函数 & 【POJ】2478 Farey Sequence & 【HDU】2824 The Euler function

    http://poj.org/problem?id=2478 http://acm.hdu.edu.cn/showproblem.php?pid=2824 欧拉函数模板裸题,有两种方法求出所有的欧拉函 ...

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

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

  3. hdu 2824 The Euler function

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

  4. hdu 2824 The Euler function 欧拉函数打表

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

  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——2824 The Euler function

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

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

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

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

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

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

    如果打表的话会超内存,我想到了一种方法解决这个问题.题目给出的数据时3000000,我将三百万分成300个数据,将整万的数据存储下来,计算的时候,先计算x和y之间整万的数据,然后再计算零散数据. 想法 ...

随机推荐

  1. shrio int配置

    之前章节我们已经接触过一些INI配置规则了,如果大家使用过如Spring之类的IoC/DI容器的话,Shiro提供的INI配置也是非常类似的,即可以理解为是一个IoC/DI容器,但是区别在于它从一个根 ...

  2. nginx大量TIME_WAIT的解决办法--转

    原文地址:http://liuyieyer.iteye.com/blog/2214722?utm_source=tuicool&utm_medium=referral 由于网站使用nginx做 ...

  3. Spatial Pyramid Matching

    转自:http://blog.csdn.net/jwh_bupt/article/details/9625469 SPM 全称是Spatial Pyramid Matching,出现的背景是bag o ...

  4. Java:JDBC操作

    内容:供程序员调用的接口与类,集成在java.sql和javax.sql包中,如:DriverManager类Connection接口Statement接口ResultSet接口 1.Class.fo ...

  5. Docker中运行MySQL5.7并挂载宿主机目录到镜像

    原文:Docker中运行MySQL5.7并挂载宿主机目录到镜像 1.1 拉取mysql镜像 docker pull mysql:5.7 1.2 创建用于挂载的目录 mkdir -p /data/mys ...

  6. cocos2dx 3.0正式版 在mac上新建项目

    触碰科技确定2.x版本号不会再更新了,会一直维护3.x的版本号.于是赶紧看看3.0的,简单浏览一下.类的使用方法和原来的几乎相同,仅仅是 表达的写法变了下,. . . . 以后肯定有非常多变化,速度熟 ...

  7. 关于命令行签名时.SF和.RSA文件的命名问题

    准备工作: 签名文件名称为android.keystore 签名的别名为123456789.keystore 1.使用签名命令后例如以下图 发现.SF和.RSA文件自己主动命名为12345678.SF ...

  8. Windows下快速安装CACTI流量监控

    Windows下快速安装CACTI流量监控 原文  http://os.51cto.com/art/201111/300977.htm CACTI是一套PHP程序,它利用SNMPGET采集数据,使用R ...

  9. AIX lsof 命令

    1.查看某端口运行情况 如查看22端口运行情况 # lsof –i:22 # lsof –i:22 –r   ----每隔15秒显示22端口的监听情况.   2.查看活动的连接 如:查看ip地址为19 ...

  10. 经典的横线中间文字css布局---flex布局

    html: <div class="title"> <div class="line"></div> <div cla ...