結果
問題 |
No.1233 割り切れない気持ち
|
ユーザー |
![]() |
提出日時 | 2024-05-02 12:36:17 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 556 bytes |
コンパイル時間 | 1,951 ms |
コンパイル使用メモリ | 192,204 KB |
最終ジャッジ日時 | 2025-02-21 10:28:59 |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 38 TLE * 1 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:10:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 10 | scanf("%d", &n); | ~~~~~^~~~~~~~~~ main.cpp:12:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 12 | scanf("%d", &a[i]); | ~~~~~^~~~~~~~~~~~~
ソースコード
#include<bits/stdc++.h> using namespace std; const int MAXN = 200001; int n, a[MAXN], Max, l, r, x; long long ans, sum[MAXN]; int main() { scanf("%d", &n); for(int i = 1; i <= n; ++i) { scanf("%d", &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(l = 1; l <= a[i]; l = r + 1) { x = a[i] / l; r = a[i] / x; ans -= 1ll * x * (sum[r] - sum[l - 1]); } } printf("%lld", ans); return 0; }