UVa10820 Send a Table[欧拉函数]】的更多相关文章

Send a TableInput: Standard Input Output: Standard Output When participating in programming contests, you sometimes face the following problem: You know how to calcutale the output for the given input values, but your algorithm is way too slow to eve…
对每个n,答案就是(phi[2]+phi[3]+...+phi[n])*2+1,简单的欧拉函数应用. #include<iostream> #include<cstdio> #include<cstdlib> #include<cstring> #include<string> #include<cmath> #include<map> #include<set> #include<list> #i…
Send a Table Input: Standard Input Output: Standard Output When participating in programming contests, you sometimes face the following problem: You know how to calcutale the output for the given input values, but your algorithm is way too slow to ev…
题意: 题目背景略去,将这道题很容易转化为,给出n求,n以内的有序数对(x, y)互素的对数. 分析: 问题还可以继续转化. 根据对称性,我们可以假设x<y,当x=y时,满足条件的只有(1, 1). 设f(n)为 集合S{(x, y) | x<y且x.y互素} 的个数,则所求答案为2f(n)+1 f(n)表达式为: ,其中φ(n)为欧拉函数 这里有欧拉函数的一些介绍 #include <cstdio> ; ], sum[maxn + ]; void phi_table(int n)…
//重点就是求1-n的欧拉函数啦,重点是nlogn求法的版 //大概过程类似于筛选法求素数 #include<cstdio> #include<iostream> #include<cmath> #include<algorithm> #include<cstring> #include<cstdlib> #include<queue> #include<vector> #include<map>…
链接: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1761 题意: 有一道比赛题目,输入两个整数x.y(1≤x,y≤n),输出某个函数f(x,y).有位选手想交表(即事先计算出所有的f(x,y),写在源代码里),但表太大了,源代码超过了比赛限制,需要精简.那道题目有一个性质,即很容易根据f(x,y)算出f(x*k, y*k)(k是任意…
Reflect Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 288    Accepted Submission(s): 174 Problem Description We send a light from one point on a mirror material circle,it reflects N times and…
题目链接: http://poj.org/problem?id=2480 题目大意:求Σgcd(i,n). 解题思路: 如果i与n互质,gcd(i,n)=1,且总和=欧拉函数phi(n). 如果i与n不互质,那么只要枚举n的全部约数,对于一个约数d,若使gcd(i/d,n/d)互质,这部分的gcd和=d*欧拉函数phi(n/d). 不断暴力从小到大枚举约数,这样就把gcd和切成好多个部分,累加起来就行了. 其实还可以公式化简,不过实在太繁琐了.可以参考金海峰神的解释. 由于要求好多欧拉函数,每次…
GCD 题意:输入N,M(2<=N<=1000000000, 1<=M<=N), 设1<=X<=N,求使gcd(X,N)>=M的X的个数.  (文末有题) 知识点:   欧拉函数.http://www.cnblogs.com/shentr/p/5317442.html 题解一: 当M==1时,显然答案为N. 当M!=1.  X是N的因子的倍数是 gcd(X,N)>1 && X<=N 的充要条件.so  先把N素因子分解, N=     …
2705: [SDOI2012]Longge的问题 Time Limit: 3 Sec  Memory Limit: 128 MBSubmit: 2553  Solved: 1565[Submit][Status][Discuss] Description Longge的数学成绩非常好,并且他非常乐于挑战高难度的数学问题.现在问题来了:给定一个整数N,你需要求出∑gcd(i, N)(1<=i <=N). Input 一个整数,为N. Output 一个整数,为所求的答案. Sample Inp…