Given the value of N , you will have to nd the value of G . The de nition of G is given below: G = i<N ∑ i =1 j N ∑ j = i +1 GCD ( i; j ) Here GCD ( i; j ) means the greatest common divisor of integer i and integer j . For those who have trouble unde…
Code: #include<cstdio> using namespace std; const int maxn=4000005; const int R=4000002; const int N=4000002; long long sumv[maxn],f[maxn]; int phi[maxn],prime[maxn],vis[maxn]; void solve(){ phi[1]=1; int cnt=0; for(int i=2;i<=R;++i){ if(!vis[i])…
突然很想刷刷题,LeetCode是一个不错的选择,忽略了输入输出,更好的突出了算法,省去了不少时间. dalao们发现了任何错误,或是代码无法通过,或是有更好的解法,或是有任何疑问和建议的话,可以在对应的随笔下面评论区留言,我会及时处理,在此谢过了. 过程或许会很漫长,也很痛苦,慢慢来吧. 编号 题名 过题率 难度 1 Two Sum 0.376 Easy 2 Add Two Numbers 0.285 Medium 3 Longest Substring Without Repeating C…