poj2478
来源:互联网 发布:宋太宗997 知乎 编辑:程序博客网 时间:2024/04/29 19:40
#include<iostream>#include<cmath>//#define LL long longtypedef long long LL;using namespace std;int phi[1000005];int enlerFun(int n) { int count = n; for(int i=2;i<=n;i++) if(n % i == 0) { count -= count / i; while(n % i == 0) n /= i; } return count; } void enlerPhi(){memset(phi,0,sizeof(phi)); for (int i = 2 ; i <= 1000003 ; i ++ ){ if( !phi[i] ){ for(int j = i ; j <= 1000003 ; j += i){ if (!phi[j]){phi [j ] = j ;} //标记合数 等于一个数 phi [j] = phi [j] / i * ( i - 1 ) ; } } }}void pt(){for(int i=1;i<=100;i++){ printf("%d(%d) ",i,phi[i]);}} LL work(LL x){ LL sum=0; for(LL i=2;i<=x;i++){ sum=sum+phi[i]; } return sum;}int main(){ enlerPhi(); //pt(); LL x; while(scanf("%I64d",&x) && x!=0){ printf("%I64d\n",work(x)); }return 0;}
0 0
- poj2478
- poj2478
- poj2478
- POJ2478
- POJ2478 Farey Sequence
- poj2478-Farey Sequence
- POJ2478 Farey Sequence
- POJ2478 Farey Sequence
- Farey Sequence(poj2478)
- [Poj2478]Farey Sequence
- poj2478(欧拉函数)
- poj2478 欧拉函数
- poj2478【欧拉函数】
- poj2478 Farey Sequence
- poj2478 Farey Sequence
- POJ2478 Farey Sequence
- [poj2478] Farey Sequence
- 快速求欧拉函数 poj2478
- ug-Assertion failure in [MyClass layoutSublayersOfLayer:]
- java内存模型
- MAC搭建LNMP环境
- poj2773
- Android layout属性大全
- poj2478
- BLE-NRF51822教程1-常用概念
- java 异常
- java.lang.RuntimeException:Unable to start activity ComponentInfo{com.meizu.beautify/com.my.viewc.Ma
- 商品的页面
- WKWebView VS UIWebView
- typedef 与#define的区别
- Centos7 Java配置
- nginx做负载均衡的常用配置