GCD Extreme (II)
Given the value of N, you will have to find the value of G. The definition of G is given below:
Here
For those who have trouble understanding summation notation, the meaning of G is given in the following code:
G=0; for(i=1;i<<span class="SpellE">N;i++) for(j=i+1;j<=N;j++) { } |
Input
The input file contains at most 100 lines of inputs. Each line contains an integer N (1
Output
For each line of input produce one line of output. This line contains the value of G for the corresponding N. The value of G will fit in a 64-bit signed integer.
Sample Input
10
100
200000
0
Output for Sample Input
67
13015
143295493160
题意: 计算gcd(1,n)+gcd(2,n)+...+gcd(n-1, n);
解题思路:
代码:
#include <cstdio>
#include <iostream>
#include <cstring>
using namespace std;
#define MAX 4000005
typedef long long ll;
int n;
ll phi[MAX], s[MAX], f[MAX];
void phi_table(int n)
{
}
void init()
{
}
int main()
{
//
}