結果

問題 No.1233 割り切れない気持ち
ユーザー MisterMister
提出日時 2020-09-18 21:53:19
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 32 ms / 3,153 ms
コード長 830 bytes
コンパイル時間 715 ms
コンパイル使用メモリ 74,332 KB
実行使用メモリ 7,972 KB
最終ジャッジ日時 2023-09-04 21:44:54
合計ジャッジ時間 3,488 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 10 ms
7,800 KB
testcase_01 AC 10 ms
7,748 KB
testcase_02 AC 10 ms
7,748 KB
testcase_03 AC 10 ms
7,804 KB
testcase_04 AC 9 ms
7,816 KB
testcase_05 AC 10 ms
7,796 KB
testcase_06 AC 9 ms
7,816 KB
testcase_07 AC 14 ms
7,832 KB
testcase_08 AC 18 ms
7,808 KB
testcase_09 AC 25 ms
7,788 KB
testcase_10 AC 27 ms
7,756 KB
testcase_11 AC 13 ms
7,756 KB
testcase_12 AC 31 ms
7,752 KB
testcase_13 AC 30 ms
7,816 KB
testcase_14 AC 31 ms
7,764 KB
testcase_15 AC 31 ms
7,836 KB
testcase_16 AC 32 ms
7,756 KB
testcase_17 AC 21 ms
7,804 KB
testcase_18 AC 27 ms
7,860 KB
testcase_19 AC 27 ms
7,860 KB
testcase_20 AC 21 ms
7,788 KB
testcase_21 AC 23 ms
7,748 KB
testcase_22 AC 23 ms
7,812 KB
testcase_23 AC 23 ms
7,748 KB
testcase_24 AC 23 ms
7,808 KB
testcase_25 AC 23 ms
7,848 KB
testcase_26 AC 22 ms
7,788 KB
testcase_27 AC 24 ms
7,800 KB
testcase_28 AC 24 ms
7,836 KB
testcase_29 AC 24 ms
7,748 KB
testcase_30 AC 24 ms
7,796 KB
testcase_31 AC 24 ms
7,748 KB
testcase_32 AC 25 ms
7,808 KB
testcase_33 AC 24 ms
7,972 KB
testcase_34 AC 25 ms
7,752 KB
testcase_35 AC 24 ms
7,804 KB
testcase_36 AC 24 ms
7,748 KB
testcase_37 AC 10 ms
7,808 KB
testcase_38 AC 20 ms
7,840 KB
testcase_39 AC 24 ms
7,764 KB
testcase_40 AC 24 ms
7,780 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0