結果
問題 | No.1233 割り切れない気持ち |
ユーザー |
![]() |
提出日時 | 2023-08-01 22:37:18 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 157 ms / 3,153 ms |
コード長 | 553 bytes |
コンパイル時間 | 1,688 ms |
コンパイル使用メモリ | 194,172 KB |
最終ジャッジ日時 | 2025-02-15 21:24:23 |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 39 |
ソースコード
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 10; int n, a[N]; vector<int> sub[N]; int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> n; for(int i = 1, x; i <= n; i ++) { cin >> x; a[x] ++; } long long ans = 0, mod = 0; for(int i = 1; i < N; i ++) { for(int j = i; j < N; j += i) sub[j].push_back(i); for(auto x : sub[i]) mod += x * (long long)a[x]; ans += a[i] * ((long long)i * n - mod); } cout << ans; }