Alex_tz307

cmmdc infopro C1 - 50 puncte

Nov 15th, 2020 (edited)
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.48 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #define int long long
  3.  
  4. using namespace std;
  5.  
  6. int32_t main() {
  7.     ios_base::sync_with_stdio(false);
  8.     cin.tie(nullptr);
  9.     cout.tie(nullptr);
  10.     int N;
  11.     cin >> N;
  12.     int ans = 0;
  13.     const int mod = 1e9 + 7;
  14.     for(int i = 2; i < N; ++i)
  15.         for(int j = i + 1; j <= N; ++j)
  16.             if(j % i) {
  17.                 int d = __gcd(i, j);
  18.                 ans = (ans + 2 * i * j % mod * d % mod) % mod;
  19.             }
  20.     cout << ans;
  21. }
Add Comment
Please, Sign In to add comment