这道题要找二元组(x, y) 满足1 <= x, y <= n 且x与y互素 那么我就可以假设x < y, 设这时答案为f(n) 那么答案就为2 * f(n) +1(x与y反过来就乘2,加上(1,1)) 那么f(n)可以用欧拉函数求 显然f(n) = phi(2) + phi(3) + --+phi(n) #include<cstdio> #define REP(i, a, b) for(int i = (a); i < (b); i++) using namespac…
Problem J GCD Extreme (II) Input: Standard Input Output: Standard Output Given the value of N, you will have to find the value of G. The definition of G is given below: Here GCD(i,j) means the greatest common divisor of integer i and integer j. For…
Chinese people think of '8' as the lucky digit. Bob also likes digit '8'. Moreover, Bob has his own lucky number L. Now he wants to construct his luckiest number which is the minimum among all positive integers that are a multiple of L and consist of…
找新朋友 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 7001 Accepted Submission(s): 3643 Problem Description 新年快到了,“猪头帮协会”准备搞一个聚会,已经知道现有会员N人,把会员从1到N编号,其中会长的号码是N号,凡是和会长是老朋友的,那么该会员的号码肯定和N有大于1的公约数…
GCD Again Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2673 Accepted Submission(s): 1123 Problem Description Do you have spent some time to think and try to solve those unsolved problem af…
GCD Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 5454 Accepted Submission(s): 1957 Problem Description Given 5 integers: a, b, c, d, k, you're to find x in a...b, y in c...d that GCD(x, y…
给整数N(1 ≤ N ≤ 1000000000),求小于N的与N不互素的所有正整数的和. 思路:1.用欧拉函数求出小于N的与N互素的正整数的个数: 2.若 p 与 N 互素,则 N-p 必与 N 互素(若 N%p==0 ,则 ( N , N-p )=p): 3.据此求出 小于N的与N互素的正整数 的和,用 小于N的所有正整数 的和减去之即可. #include<iostream> #include<cstdio> using namespace std; long long n,s…
Longge's problem Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 9190 Accepted: 3073 Description Longge is good at mathematics and he likes to think about hard mathematical problems which will be solved by some graceful algorithms. Now…
题目链接 做过\(n\)遍这种题了... 答案就是\(\sum_{i=1}^{n}\sum_{j=1}^{n/i}[\varphi(j)*i]\) 线筛欧拉函数求前缀和直接算就行. #include <cstdio> const int MAXN = 2000010; int v[MAXN], prime[MAXN], cnt, n; long long ans, phi[MAXN]; int main(){ scanf("%d", &n); phi[1] = 1;…
GCD 描述 The greatest common divisor GCD(a,b) of two positive integers a and b,sometimes written (a,b),is the largest divisor common to a and b,For example,(1,2)=1,(12,18)=6. (a,b) can be easily found by the Euclidean algorithm. Now Carp is considering…
Become A Hero Time Limit: 15000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 210 Accepted Submission(s): 57 Problem Description Lemon wants to be a hero since he was a child. Recently he is reading a book…