結果

問題 No.1233 割り切れない気持ち
ユーザー MisterMister
提出日時 2020-09-18 21:52:32
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 828 bytes
コンパイル時間 1,769 ms
コンパイル使用メモリ 74,640 KB
実行使用メモリ 7,132 KB
最終ジャッジ日時 2023-09-04 19:03:28
合計ジャッジ時間 4,152 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 9 ms
6,936 KB
testcase_01 AC 9 ms
6,920 KB
testcase_02 AC 9 ms
6,928 KB
testcase_03 AC 9 ms
6,872 KB
testcase_04 AC 8 ms
7,108 KB
testcase_05 AC 9 ms
6,904 KB
testcase_06 AC 9 ms
7,128 KB
testcase_07 AC 14 ms
6,996 KB
testcase_08 AC 16 ms
6,928 KB
testcase_09 AC 23 ms
6,996 KB
testcase_10 AC 25 ms
6,876 KB
testcase_11 AC 13 ms
7,132 KB
testcase_12 AC 27 ms
6,948 KB
testcase_13 AC 27 ms
6,940 KB
testcase_14 AC 27 ms
7,056 KB
testcase_15 AC 27 ms
6,992 KB
testcase_16 AC 27 ms
6,928 KB
testcase_17 AC 19 ms
6,916 KB
testcase_18 AC 25 ms
6,940 KB
testcase_19 WA -
testcase_20 AC 19 ms
6,884 KB
testcase_21 AC 22 ms
6,880 KB
testcase_22 AC 22 ms
6,996 KB
testcase_23 AC 22 ms
6,964 KB
testcase_24 AC 22 ms
6,880 KB
testcase_25 AC 23 ms
6,920 KB
testcase_26 AC 22 ms
6,900 KB
testcase_27 AC 23 ms
6,880 KB
testcase_28 AC 23 ms
6,924 KB
testcase_29 AC 24 ms
6,900 KB
testcase_30 AC 24 ms
7,104 KB
testcase_31 AC 23 ms
6,960 KB
testcase_32 AC 23 ms
6,904 KB
testcase_33 AC 23 ms
7,000 KB
testcase_34 AC 23 ms
6,884 KB
testcase_35 AC 23 ms
7,108 KB
testcase_36 AC 23 ms
7,084 KB
testcase_37 AC 9 ms
6,964 KB
testcase_38 AC 19 ms
6,996 KB
testcase_39 AC 22 ms
6,884 KB
testcase_40 AC 23 ms
6,884 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<int> 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 (int 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