uva10820 send a table (nlogn求1-n欧拉函数值模版
//重点就是求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欧拉函数值模版的更多相关文章
- 2019-ACM-ICPC-南昌区网络赛-H. The Nth Item-特征根法求通项公式+二次剩余+欧拉降幂
2019-ACM-ICPC-南昌区网络赛-H. The Nth Item-特征根法求通项公式+二次剩余+欧拉降幂 [Problem Description] 已知\(f(n)=3\cdot f(n ...
- UVa10820 Send a Table[欧拉函数]
Send a TableInput: Standard Input Output: Standard Output When participating in programming contests ...
- UVA10820 Send a Table
嘟嘟嘟 [欧拉函数] 大致题意:如果知道f(a, b),就可以求出f(a * k, b * k).现给出一个n,求至少需要知道几个二元组(a, b),使所有的f(x, y)都能求出来.(1 <= ...
- 初等数论-Base-1(筛法求素数,欧拉函数,欧几里得算法)
前言 初等数论在OI中应用的基础部分,同机房的AuSquare和zhou2003君早就写完了,一直划水偷懒的Hk-pls表示很方,这才开始了这篇博客. \(P.S.\)可能会分部分发表. Base-1 ...
- UVA 10820 - Send a Table 数论 (欧拉函数)
Send a Table Input: Standard Input Output: Standard Output When participating in programming contest ...
- UVa 10820 - Send a Table
题目:找到整数区间[1.n]中全部的互质数对. 分析:数论,筛法,欧拉函数.在筛素数的的同一时候.直接更新每一个数字的欧拉函数. 每一个数字一定会被他前面的每一个素数筛到.而欧拉函数的计算是n*π(1 ...
- 交表(Send a Table)
#include<stdio.h> #include<string.h> #define N 50010 int phi[N],n,sum[N]; void phi_table ...
- 【poj2478-Farey Sequence】递推求欧拉函数-欧拉函数的几个性质和推论
http://poj.org/problem?id=2478 题意:给定一个数x,求<=x的数的欧拉函数值的和.(x<=10^6) 题解:数据范围比较大,像poj1248一样的做法是不可行 ...
- 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 ...
随机推荐
- C# 如何查看源程序的IL代码
1.打开microsoft visual studio 2008 / visual studio tools / visual studio 2008 命令提示 ,并输入ilda ...
- lisp构造表
CONS 操作符 我们刚刚学习了如何拆分一个表,现在学习如何合并一个表. CONS 操作符就是做这件事情的. 假设有一个列表 (1 2 3) ,我们做一下 CAR 操作: (car '(1 2 3)) ...
- 常用财务软件:用友,金蝶,新中大,速达,管家婆,金算盘,远方,远光,金钥匙,润衡,浪潮,上海博科,易商,任我行,千方百剂,智管,小蜜蜂,SAP,ORACLE,SSA,QAD,MAPICS,JDE。
常用财务软件:用友,金蝶,新中大,速达,管家婆,金算盘,远方,远光,金钥匙,润衡,浪潮,上海博科,易商,任我行,千方百剂,智管,小蜜蜂,SAP,ORACLE,SSA,QAD,MAPICS,JDE. 申 ...
- Binary Tree Zigzag Level Order Traversal 解答
Question Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, fro ...
- centos directory server
http://www.aliyun.com/zixun/content/3_12_517262.html CentOS系统安装Directory Server 8.1操作方法 发布时间:2014-12 ...
- CDH 2、Cloudera Manager的安装
1.Cloudera Manager • Cloudera Manager是一个管理CDH的端到端的应用. • 作用: – 管理 – 监控 – 诊断 – 集成 • 架构 • Server – 管理控制 ...
- #include<string.h>
#include<string.h> 1 strcpy #include <string.h> char *strcpy(char *str1, const char *str ...
- OGG常见问题处理
1403: ORA-01403: No data found 在运行PL/SQL块.存储过程.函数.触发器等,假设须要进行操作的记录没有查询到.则会返回1403的错误 Goldengate中的1403 ...
- ADO.net基础学习总结
ADO.net是一门.net连接.操作数据库的技术 释放资源:凡是实现了idisposable借口的类都需要用using来释放资源 using() { } 连接数据库 //创建数据库连接: usi ...
- Perfect Squares
Perfect Squares Total Accepted: 18854 Total Submissions: 63048 Difficulty: Medium Given a positive i ...