A、小G的sum
题目分析:
代码如下:
#include<iostream> using namespace std; int main(){ long long n; cin >> n; cout<<n+n*(n+1)/2; return 0; }
B、小G的GCD
题目分析:
代码如下:
#include<iostream> using namespace std; typedef long long ll; ll n,k; int main(){ cin >> n >> k; ll ans = 0; for(int i = k; i <= n; i ++ ) ans += (i/k)*(k + (i/k)*k)/2; cout<<ans; return 0; }
C、小G的约数
题目分析:
代码如下:
#include<cstdio> #include<cstring> #include<iostream> #include<algorithm> using namespace std; typedef long long ll; ll n; ll G(ll n){ ll ans = 0; for(ll l = 1,r; l <= n; l = r + 1){ r = n/(n/l); ans += (r - l + 1)*(l + r)/2*(n/l); } return ans; } int main(){ cin >> n; cout<<G(G(n)); return 0; }