結果
問題 | No.1233 割り切れない気持ち |
ユーザー |
|
提出日時 | 2020-09-18 21:53:19 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 29 ms / 3,153 ms |
コード長 | 830 bytes |
コンパイル時間 | 685 ms |
コンパイル使用メモリ | 73,612 KB |
最終ジャッジ日時 | 2025-01-14 17:02:47 |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 39 |
ソースコード
#include <iostream>#include <numeric>#include <vector>using lint = long long;constexpr int X = 200000;void solve() {int n;std::cin >> n;std::vector<lint> cnt(X + 1, 0);for (int i = 0; i < n; ++i) {int x;std::cin >> x;++cnt[x];}std::vector<lint> sums(X + 1, 0);for (lint x = 1; x <= X; ++x) {for (int y = x; y <= X; y += x) {sums[y] += cnt[x] * x;}}for (int i = 1; i <= X; ++i) sums[i] += sums[i - 1];std::vector<lint> vals(X + 1);for (lint i = 0; i <= X; ++i) vals[i] = i * n - sums[i];lint ans = 0;for (int x = 0; x <= X; ++x) ans += cnt[x] * vals[x];std::cout << ans << "\n";}int main() {std::cin.tie(nullptr);std::ios::sync_with_stdio(false);solve();return 0;}