//重点就是求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. Android 圆形按钮实现

    项目中用到的圆形按钮,做个半天,用sharp形式实现,样式代码如下: <Button android:id="@+id/btn_5" android:layout_width ...

  2. Working——流程关系状态表

    --主表单 select * from ce_administration_procure t where t.id ='HZe992733d668dc6013d671df4760349'; --流程 ...

  3. bzoj1641 [Usaco2007 Nov]Cow Hurdles 奶牛跨栏

    Description Farmer John 想让她的奶牛准备郡级跳跃比赛,贝茜和她的伙伴们正在练习跨栏.她们很累,所以她们想消耗最少的能量来跨栏. 显然,对于一头奶牛跳过几个矮栏是很容易的,但是高 ...

  4. Android APK安装包瘦身[转]

    很显然,APK安装包越小越好.下面从代码,资源文件,使用策略几个方面简要介绍下: 代码 保持良好的编程习惯,不要重复或者不用的代码,谨慎添加libs,移除使用不到的libs. 使用proguard混淆 ...

  5. UESTC_Rain in ACStar 2015 UESTC Training for Data Structures<Problem L>

    L - Rain in ACStar Time Limit: 9000/3000MS (Java/Others)     Memory Limit: 65535/65535KB (Java/Other ...

  6. ZOJ3761(并查集+树的遍历)

    Easy billiards Time Limit: 2 Seconds      Memory Limit: 65536 KB      Special Judge Edward think a g ...

  7. 遍历父视图上的button

    for (UIView * thebtn in [self.view subviews]) { if ([thebtn isKindOfClass:[UIButton class]]) { //*** ...

  8. Unity NGUI 血条制作

    NGUI 血条制作步骤 实现过程: 模拟血条的变化当点击按钮Button是血条会实时发生变化. 1.向Unity中导入NGUI2.6.3.unitypackage 点击create your ui 后 ...

  9. WebService调用1(.Net)

    1.创建一个最简单的Web Service (1)  新建-项目-ASP.NET空WEB应用程序 (2)添加新项-WEB服务 默认会添加一个HelloWorld方法: using System; us ...

  10. 一.Linq to JSON是用来干什么的?

    Linq to JSON是用来操作JSON对象的.可以用于快速查询,修改和创建JSON对象.当JSON对象内容比较复杂,而我们仅仅需要其中的一小部分数据时,可以考虑使用Linq to JSON来读取和 ...