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 ;
}

最新文章

  1. cefsharp设置网页接受语言Accept-Language
  2. 【转载】SQL Server 2008 r2 中 SQL语句中单引号转义
  3. 三部曲一(数据结构)-1020-Ultra-QuickSort
  4. A Guide to Creating a Quality Project Schedule
  5. HFile解析 基于0.96
  6. 更改git bash默认的路径
  7. Linux 普通用户su命令切换控制
  8. IOS-图片上传到服务器
  9. php环境下ckeditor和ckfinder的配置详解
  10. poj2521---lose money
  11. Shell的学习就从重装系统开始吧
  12. JSP学习(一)之中文乱码问题的解决
  13. listview优化加强版
  14. springboot学习(一)——helloworld
  15. Java基础:一个100%会发生死锁的程序
  16. ueditor的简单用法
  17. 1. ansible-playbook 变量定义与引用
  18. git设置ss代理
  19. 单独配置secondarynamenode
  20. ASP.NET网站伪静态下使用中文URL

热门文章

  1. 轻松python专题--文本
  2. POJ 2436 二进制枚举
  3. Httpd 文件服务器的搭建
  4. 使用IntelliJ IDEA开发前的基本设置,有助于提高开发效率
  5. Maven实战(八)---模块划分
  6. List与array的相互转换
  7. Android Studio升级到0.8.1后怎样设置字体大小?
  8. unity 获取物体尺寸
  9. Zabbix + Grafana
  10. Laravel输出sql语句