HDU——T 2824 The Euler function
2024-08-27 02:06:36
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 ;
}
最新文章
- cefsharp设置网页接受语言Accept-Language
- 【转载】SQL Server 2008 r2 中 SQL语句中单引号转义
- 三部曲一(数据结构)-1020-Ultra-QuickSort
- A Guide to Creating a Quality Project Schedule
- HFile解析 基于0.96
- 更改git bash默认的路径
- Linux 普通用户su命令切换控制
- IOS-图片上传到服务器
- php环境下ckeditor和ckfinder的配置详解
- poj2521---lose money
- Shell的学习就从重装系统开始吧
- JSP学习(一)之中文乱码问题的解决
- listview优化加强版
- springboot学习(一)——helloworld
- Java基础:一个100%会发生死锁的程序
- ueditor的简单用法
- 1. ansible-playbook 变量定义与引用
- git设置ss代理
- 单独配置secondarynamenode
- ASP.NET网站伪静态下使用中文URL