結果

問題 No.1233 割り切れない気持ち
ユーザー merom686merom686
提出日時 2020-09-18 22:30:40
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 26 ms / 3,153 ms
コード長 829 bytes
コンパイル時間 840 ms
コンパイル使用メモリ 87,244 KB
実行使用メモリ 5,652 KB
最終ジャッジ日時 2023-09-04 21:50:38
合計ジャッジ時間 3,226 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
5,384 KB
testcase_01 AC 3 ms
5,480 KB
testcase_02 AC 5 ms
5,460 KB
testcase_03 AC 5 ms
5,460 KB
testcase_04 AC 6 ms
5,428 KB
testcase_05 AC 5 ms
5,360 KB
testcase_06 AC 5 ms
5,412 KB
testcase_07 AC 11 ms
5,476 KB
testcase_08 AC 14 ms
5,432 KB
testcase_09 AC 22 ms
5,584 KB
testcase_10 AC 22 ms
5,488 KB
testcase_11 AC 11 ms
5,652 KB
testcase_12 AC 26 ms
5,364 KB
testcase_13 AC 25 ms
5,428 KB
testcase_14 AC 25 ms
5,416 KB
testcase_15 AC 25 ms
5,420 KB
testcase_16 AC 26 ms
5,480 KB
testcase_17 AC 14 ms
5,368 KB
testcase_18 AC 24 ms
5,440 KB
testcase_19 AC 21 ms
5,452 KB
testcase_20 AC 14 ms
5,376 KB
testcase_21 AC 17 ms
5,368 KB
testcase_22 AC 17 ms
5,432 KB
testcase_23 AC 17 ms
5,628 KB
testcase_24 AC 18 ms
5,468 KB
testcase_25 AC 17 ms
5,496 KB
testcase_26 AC 17 ms
5,424 KB
testcase_27 AC 19 ms
5,428 KB
testcase_28 AC 19 ms
5,420 KB
testcase_29 AC 18 ms
5,364 KB
testcase_30 AC 19 ms
5,436 KB
testcase_31 AC 19 ms
5,448 KB
testcase_32 AC 19 ms
5,364 KB
testcase_33 AC 19 ms
5,480 KB
testcase_34 AC 18 ms
5,488 KB
testcase_35 AC 18 ms
5,368 KB
testcase_36 AC 18 ms
5,384 KB
testcase_37 AC 4 ms
5,368 KB
testcase_38 AC 14 ms
5,436 KB
testcase_39 AC 19 ms
5,368 KB
testcase_40 AC 20 ms
5,428 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;

    int m = (int)2e+5 + 1;
    vector<int> b(m, 0);
    vector<ll> s(m, 0);
    ll r = 0;

    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;

        b[a]++;
        r += a;
    }
    r *= n;

    for (int a = 1; a < m; a++) {
        ll t = b[a];
        if (t == 0) continue;

        t *= a;
        for (int j = a; j < m; j += a) {
            s[j] += t;
        }
    }
    for (int j = 1; j < m; j++) {
        s[j] += s[j - 1];
    }

    for (int j = 1; j < m; j++) {
        r -= s[j] * b[j];
    }

    cout << r << endl;

    return 0;
}
0