Advertisement
tuki2501

MATONG.cpp

Nov 25th, 2021
940
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.36 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. typedef long long ll;
  5.  
  6. const int N = 1000001;
  7.  
  8. int cnt[N];
  9.  
  10. signed main() {
  11.   for (int i = 1; i < N; i++)
  12.   for (int j = i; j < N; j += i) {
  13.     cnt[j]++;
  14.   }
  15.   int n; cin >> n;
  16.   ll ans = 0;
  17.   for (int i = 1; i <= n; i++) {
  18.     int x; cin >> x;
  19.     ans += x * cnt[x];
  20.   }
  21.   cout << ans << '\n';
  22. }
  23.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement