結果
問題 |
No.2046 Ans Mod? Mod Ans!
|
ユーザー |
|
提出日時 | 2022-12-14 03:29:07 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,107 bytes |
コンパイル時間 | 849 ms |
コンパイル使用メモリ | 66,944 KB |
最終ジャッジ日時 | 2025-02-09 11:22:03 |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 10 WA * 8 |
ソースコード
#include <iostream> using namespace std; typedef long long ll; const int M = 200000; int main() { int n; cin >> n; bool b[200005]{0}; int d[200005]{0}; for (int i = 0; i < n; i++) { int a; cin >> a; b[a] = true; d[a] = a; } ll c[200005], s[200005]; c[0] = s[0] = 0; for (int i = 1; i <= M + 1; i++) { c[i] = c[i - 1] + b[i - 1]; s[i] = s[i - 1] + d[i - 1]; } ll ans = 0; int e = 0; for (int i = 1; i <= M; i++) { if (b[i]) { ans += i * (n - e - 1); e++; } } for (int i = M; i > 0; i--) { if (!b[i]) { continue; } int r = i; for (int j = 2; j * j <= i; j++) { int l = i / j + 1; ans -= -(s[r] - s[l]) * (j - 1) + (c[r] - c[l]) * (i % l + l * (j - 1)); r = l; } for (int j = 1; j < r; j++) { if (b[j]) { ans -= i % j; } } } cout << ans << endl; }