HDU 2824 The Euler function 欧拉函数
来源:互联网 发布:淘宝用打印机什么牌子 编辑:程序博客网 时间:2024/05/21 10:42
欧拉函数裸题,直接上代码:
#include<stdio.h>#include<string.h>#include<stdlib.h>#include<algorithm>#include<iostream>#include<vector>using namespace std;#define MAX 3000100int p[MAX],ans[MAX];bool a[MAX];int A,B;int main(){ //freopen("input.in","r",stdin); //freopen("output.out","w",stdout); int num=0; for(int i=2;i<=3000001;i++) { if(!a[i]) { p[num++]=i; ans[i]=i-1; } for(int j=0;j<num && p[j]*i<=3000001;j++) { a[p[j]*i]=true; if(!(i%p[j])) { ans[i*p[j]]=ans[i]*p[j]; break; } else ans[i*p[j]]=ans[i]*(p[j]-1); } } while(scanf("%d%d",&A,&B)!=EOF) { __int64 ans1=0; for(int i=A;i<=B;i++) ans1=ans1+ans[i]; printf("%I64d\n",ans1); } //system("pause"); return 0;}
转载注明出处:http://blog.csdn.net/u011400953
0 0
- hdu 2824 The Euler function(欧拉函数)
- hdu 2824 The Euler function 欧拉函数模板题
- HDU 2824 The Euler function 欧拉函数
- hdu 2824 The Euler function(欧拉函数)
- HDU-#2824 The Euler function(欧拉函数+筛法)
- HDU 2824 The Euler function(欧拉函数)
- HDU 2824 The Euler function(欧拉函数)
- HDU 2824 The Euler function【欧拉函数 打表】
- HDU 2824 The Euler function(欧拉函数)
- HDU 2824 The Euler function [欧拉函数]
- hdu 2824 The Euler function(欧拉函数)
- HDU 2824 The Euler function【欧拉函数入门题】
- hdu 2824 The Euler function (欧拉函数离线模板)
- HDU:2824 The Euler function(欧拉函数)
- 【HDU 2824 The Euler function】+ 欧拉函数
- hdu 2824 The Euler function(欧拉函数)
- 2824 The Euler function【欧拉函数】
- HDU The Euler function (欧拉函数打表)
- java学习笔记(七)——排序算法
- Linux环境常用工具
- 存储器层次结构--利用高速缓存提升程序性能
- cookie 和session 的区别详解
- 不是吓唬你,工程师不知道谷歌的深度学习系统在想什么
- HDU 2824 The Euler function 欧拉函数
- 我的解决libzbar开源库识别时乱码的问题
- Android NDK纯C++开发(2)
- K245上偶遇的小女孩
- WIKIOI 1344 线型网络 题解与分析
- Plus One
- Oracle 删除重复数据只留一条
- Canvas与Region.Op入门
- 485通讯接口与232接口的区别