HDU2824 The Euler function 欧拉函数的应用
来源:互联网 发布:vi系统 知乎 编辑:程序博客网 时间:2024/05/29 06:38
题目意思就是求 a 到 b 的欧拉函数值的和 ,注意本题的范围 是 3000000,所以不要用线性的 欧拉函数模版,因为那个模版要开三个数组,所以内存会很大,直接用普通的就可以了,坑了我好久的爆内存,还有 请我自己记住啊 __int64
#include<iostream>#include<cstdio>#include<list>#include<algorithm>#include<cstring>#include<string>#include<queue>#include<stack>#include<map>#include<vector>#include<cmath>#include<memory.h>#include<set>#define ll long long#define LL __int64#define eps 1e-8//const ll INF=9999999999999;#define inf 0xfffffffusing namespace std;//vector<pair<int,int> > G;//typedef pair<int,int> P;//vector<pair<int,int>> ::iterator iter;////map<ll,int>mp;//map<ll,int>::iterator p;////vector<int>G[30012];const int maxp = 3000001;LL phi[maxp];void init()//筛选法求欧拉函数的模版,比线性的慢,但是不消耗内存{ memset(phi, 0, sizeof(phi)); phi[1] = 1; for(int i = 2; i < maxp; i++) if(!phi[i]) { for(int j = i; j < maxp; j+=i) { if(!phi[j]) phi[j] = j; phi[j] = phi[j] / i * (i-1); } } return ;}int main(void){init();int a,b;while(scanf("%d %d",&a,&b)==2){LL ans=0;for(int i=a;i<=b;i++)ans+=phi[i];printf("%I64d\n",ans);}}
- HDU2824 The Euler function 欧拉函数的应用
- hdu2824 The Euler function (欧拉函数)
- hdu2824 The Euler function 欧拉函数
- hdu2824 The Euler function 欧拉函数
- hdu2824 The Euler function 欧拉函数模板题
- hdu2824 The Euler function(欧拉函数个数)
- The Euler function(hdu2824,欧拉函数)
- 欧拉函数之HDU2824 The Euler function
- hdu2824-The Euler function
- hdu2824-The Euler function
- hdu2824:The Euler function
- hdu2824 The Euler function
- hdu2824(the Euler Function)
- The Euler function(欧拉函数)
- 2824 The Euler function【欧拉函数】
- The Euler function【欧拉函数】
- hdu2824 The Euler function 筛选法求欧拉函数模板题
- hdu2824(欧拉函数)
- oracle动态sql
- button.setRolloverIcon的使用
- 编写一个程序,实现顺序环形队列的各种基本运算。
- ARM裸机之系统时钟
- JScrollPane的使用
- HDU2824 The Euler function 欧拉函数的应用
- 位运算
- Accelerated C++ exercises 4-0
- Java NIO学习
- Oracle数据库scoot用户经典查询语句
- CMUSphinx Learn - Building application with pocketsphinx
- gcc基本指令+gdb调试
- (-)第114天的交易(2013-11-13)(-50)(-69)
- Undefined reference to” 的处理