SPOJ:NT Games(欧拉函数)】的更多相关文章

题目描述 Given n, calculate the sum LCM(1,n) + LCM(2,n) + .. + LCM(n,n), where LCM(i,n) denotes the Least Common Multiple of the integers i and n. 输入 The first line contains T the number of test cases. Each of the next T lines contain an integer n. 输出 Ou…
Katniss Everdeen after participating in Hunger Games now wants to participate in NT Games (Number Theory Games). As she begins President Snow provides her a number k. Then, she has to defend t back to back attacks from Haymitch Abernathy for practice…
[BZOJ2226][Spoj 5971] LCMSum Description Given n, calculate the sum LCM(1,n) + LCM(2,n) + .. + LCM(n,n), where LCM(i,n) denotes the Least Common Multiple of the integers i and n. Input The first line contains T the number of test cases. Each of the n…
5152. Brute-force Algorithm EXTREME Problem code: BFALG Please click here to download a PDF version of the contest problems. The problem is problem B in the PDF. But the data limits is slightly modified: 1≤P≤1000000 in the original description, but i…
1363 最小公倍数之和 题目来源: SPOJ 基准时间限制:1.5 秒 空间限制:131072 KB 分值: 160 给出一个n,求1-n这n个数,同n的最小公倍数的和.例如:n = 6,1,2,3,4,5,6 同6的最小公倍数分别为6,6,6,12,30,6,加在一起 = 66. 由于结果很大,输出Mod 1000000007的结果. Input 第1行:一个数T,表示后面用作输入测试的数的数量.(1 <= T <= 50000) 第2 - T + 1行:T个数A[i](A[i] <…
题目: SPOJ-GCDEX (洛谷 Remote Judge) 分析: 求: \[\sum_{i=1}^{n}\sum_{j=i+1}^{n}gcd(i,j)\] 这道题给同届新生讲过,由于种种原因只讲了 \(O(n)\) 预处理欧拉函数 \(O(n)\) 查询的暴力做法,顺带提了一句 "这题能根号查询" 被教练嘴了 QAQ .以及小恐龙给我说有 \(O(n\log n)\) 预处理 \(O(1)\) 查询的另一种写法. 重点是前几天某学长讲课讲这道题,才知道有 \(O(n)\) 预…
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…
2818: Gcd Time Limit: 10 Sec  Memory Limit: 256 MBSubmit: 4436  Solved: 1957[Submit][Status][Discuss] Description 给定整数N,求1<=x,y<=N且Gcd(x,y)为素数的数对(x,y)有多少对. 1<=N<=10^7 uva上做过gcd(x,y)=1的题 gcd(x,y)=p ---> gcd(x/p,y/p)=1 每个质数做一遍行了 答案是欧拉函数的前缀和*2…
题目:http://cogs.pw/cogs/problem/problem.php?pid=2533 这道题考察打表观察规律. 发现对f的定义实际是递归式的 f(n,k) = f(0,f(n-1,k)) f(0,k) = balabalabalabala 所以,实际上的f(n,k)是这么个东西 f(0,(0,(0,(0,(0,(0,(0,(0,k)))))))) 直接递归求解并打出表来,我们可以发现这样的事实 f(0,k) = k+1 所以有f(n,k) = n + k + 1; 所以题目就转…