結果
問題 | No.1233 割り切れない気持ち |
ユーザー |
![]() |
提出日時 | 2024-05-02 12:16:57 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 536 bytes |
コンパイル時間 | 1,831 ms |
コンパイル使用メモリ | 200,312 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-23 01:58:01 |
合計ジャッジ時間 | 33,808 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 38 TLE * 1 |
ソースコード
#include<bits/stdc++.h> using namespace std; const int MAXN = 200001; int n, a[MAXN], Max; long long ans, sum[MAXN]; int main() { cin >> n; for(int i = 1; i <= n; ++i) { cin >> a[i]; sum[a[i]] += a[i], ans += 1ll * a[i] * n, Max = max(Max, a[i]); } for(int i = 1; i <= Max; ++i) { sum[i] += sum[i - 1]; } for(int i = 1; i <= n; ++i) { for(int l = 1, r; l <= a[i]; l = r + 1) { int x = a[i] / l; r = a[i] / x; ans -= 1ll * x * (sum[r] - sum[l - 1]); } } cout << ans; return 0; }