//重点就是求1-n的欧拉函数啦,重点是nlogn求法的版

//大概过程类似于筛选法求素数

 #include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include<string> using namespace std; int n;
int phi[];
int f[]; int main(){
memset(phi,,sizeof(phi));
memset(f,,sizeof(f));
phi[]=;
for (int i=;i<=;i++){
if (phi[i]==){
for (int j=i;j<=;j+=i){
if (phi[j]==) phi[j]=j;
phi[j]=phi[j]/i*(i-);
}
}
}
for (int i=;i<=;i++) f[i]=f[i-]+phi[i];
while (scanf("%d",&n)==){
if (n==) return ;
printf("%d\n",f[n]*-);
}
return ;
}
/*
2
5
0
*/

uva10820 send a table (nlogn求1-n欧拉函数值模版的更多相关文章

  1. 2019-ACM-ICPC-南昌区网络赛-H. The Nth Item-特征根法求通项公式+二次剩余+欧拉降幂

    2019-ACM-ICPC-南昌区网络赛-H. The Nth Item-特征根法求通项公式+二次剩余+欧拉降幂 [Problem Description] ​ 已知\(f(n)=3\cdot f(n ...

  2. UVa10820 Send a Table[欧拉函数]

    Send a TableInput: Standard Input Output: Standard Output When participating in programming contests ...

  3. UVA10820 Send a Table

    嘟嘟嘟 [欧拉函数] 大致题意:如果知道f(a, b),就可以求出f(a * k, b * k).现给出一个n,求至少需要知道几个二元组(a, b),使所有的f(x, y)都能求出来.(1 <= ...

  4. 初等数论-Base-1(筛法求素数,欧拉函数,欧几里得算法)

    前言 初等数论在OI中应用的基础部分,同机房的AuSquare和zhou2003君早就写完了,一直划水偷懒的Hk-pls表示很方,这才开始了这篇博客. \(P.S.\)可能会分部分发表. Base-1 ...

  5. UVA 10820 - Send a Table 数论 (欧拉函数)

    Send a Table Input: Standard Input Output: Standard Output When participating in programming contest ...

  6. UVa 10820 - Send a Table

    题目:找到整数区间[1.n]中全部的互质数对. 分析:数论,筛法,欧拉函数.在筛素数的的同一时候.直接更新每一个数字的欧拉函数. 每一个数字一定会被他前面的每一个素数筛到.而欧拉函数的计算是n*π(1 ...

  7. 交表(Send a Table)

    #include<stdio.h> #include<string.h> #define N 50010 int phi[N],n,sum[N]; void phi_table ...

  8. 【poj2478-Farey Sequence】递推求欧拉函数-欧拉函数的几个性质和推论

    http://poj.org/problem?id=2478 题意:给定一个数x,求<=x的数的欧拉函数值的和.(x<=10^6) 题解:数据范围比较大,像poj1248一样的做法是不可行 ...

  9. UVA12493 - Stars(求1-N与N互质的个数)欧拉函数

    Sample Input 3 4 5 18 36 360 2147483647 Sample Output 1 1 2 3 6 48 1073741823 题目链接:https://uva.onlin ...

随机推荐

  1. [置顶] SPL讲解(7)--Query高级篇

    SmartPersistenceLayer 2.0 之Query高级查询篇 总述 在看了前面的功能后,大家都会考虑到多表之间的查询怎么办.在这里,我想先讲一下查询在应用系统中的复杂性/重要性/可行性. ...

  2. shell重定向

    输入重定向 和输出重定向一样,Unix 命令也可以从文件获取输入,语法为: command < file 这样,本来需要从键盘获取输入的命令会转移到文件读取内容. 注意:输出重定向是大于号(&g ...

  3. Unix/Linux环境C编程入门教程(35) 编程管理系统中的组

     组管理相关函数介绍 相关函数 getgid,setgid,setregid 表头文件 #include<unistd.h> #include<sys/types.h> 定 ...

  4. DataTable转换成List

    public static List<T> GetList<T>(DataTable table) { List<T> list = new List<T&g ...

  5. SPOJ GCDEX (数论)

    转载请注明出处,谢谢http://blog.csdn.net/ACM_cxlove?viewmode=contents    by---cxlove 题意:求sigma (gcd (i , j))  ...

  6. 单调队列-hdu-4193-Non-negative Partial Sums

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=4193 题目大意: 给n个数,a0,a1,...an,求ai,ai+1,...an,a1,a2,... ...

  7. android:强大的图片下载和缓存库Picasso

    1.Picasso简单介绍 Picasso是Square公司出品的一个强大的图片下载和缓存图片库.官方网址是:http://square.github.io/picasso/ 仅仅须要一句代码就能够将 ...

  8. 【计算几何初步-线段相交】【HDU1089】线段交点

    You can Solve a Geometry Problem too Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/3 ...

  9. Hortonworks 用于做 Sentimental Analysis的Hiveddl.sql 文件

    The hiveddl.sql script has performed the following steps to refine the data: Converted the raw Twitt ...

  10. django的路由系统

    在django生成的工程项目文件中urls.py文件用于指定路由信息 该文件默认导入以下模块 from confimport from import admin from confimport url ...