結果
問題 | No.1233 割り切れない気持ち |
ユーザー |
![]() |
提出日時 | 2024-05-02 10:35:43 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2,550 ms / 3,153 ms |
コード長 | 661 bytes |
コンパイル時間 | 1,724 ms |
コンパイル使用メモリ | 191,976 KB |
最終ジャッジ日時 | 2025-02-21 10:14:48 |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 39 |
ソースコード
#include<bits/stdc++.h> using namespace std; using LL = long long; const int N = 2e5 + 5, MAXN = 2e5; int n, a[N], vis[N]; LL sum[N], cnt[N], ans, now; int main(){ ios::sync_with_stdio(0), cin.tie(0); cin >> n; for(int i = 1; i <= n; ++i){ cin >> a[i]; cnt[a[i]] += a[i]; vis[a[i]]++; } for(int i = 0; i <= MAXN; ++i){ sum[i] = sum[i - 1] + cnt[i]; } for(int i = 0; i <= MAXN; ++i){ now = 0; for(int l = 1, r; l <= i; l = r + 1){ r = i / (i / l); now += 1ll * i / l * (sum[r] - sum[l - 1]); } ans += (1ll * n * i - now) * vis[i]; } cout << ans; return 0; } /* a[i] - (a[i] / a[j]) * a[j]; */