結果

問題 No.1233 割り切れない気持ち
ユーザー YamaKasaYamaKasa
提出日時 2020-09-19 17:32:55
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,508 bytes
コンパイル時間 1,620 ms
コンパイル使用メモリ 169,976 KB
実行使用メモリ 17,732 KB
最終ジャッジ日時 2023-09-05 22:48:14
合計ジャッジ時間 6,490 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,884 KB
testcase_01 AC 3 ms
4,948 KB
testcase_02 AC 5 ms
4,820 KB
testcase_03 AC 6 ms
4,856 KB
testcase_04 AC 6 ms
5,000 KB
testcase_05 AC 4 ms
4,816 KB
testcase_06 AC 5 ms
4,816 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 32 ms
6,988 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 32 ms
6,480 KB
testcase_18 WA -
testcase_19 AC 63 ms
6,616 KB
testcase_20 AC 33 ms
6,544 KB
testcase_21 AC 50 ms
6,508 KB
testcase_22 AC 51 ms
6,380 KB
testcase_23 AC 50 ms
6,556 KB
testcase_24 AC 50 ms
6,476 KB
testcase_25 AC 51 ms
6,444 KB
testcase_26 AC 50 ms
6,752 KB
testcase_27 AC 60 ms
7,180 KB
testcase_28 AC 61 ms
7,412 KB
testcase_29 AC 60 ms
7,332 KB
testcase_30 AC 59 ms
6,996 KB
testcase_31 AC 60 ms
7,020 KB
testcase_32 AC 59 ms
6,920 KB
testcase_33 AC 60 ms
6,884 KB
testcase_34 AC 59 ms
6,912 KB
testcase_35 AC 60 ms
6,936 KB
testcase_36 AC 60 ms
6,804 KB
testcase_37 AC 3 ms
5,092 KB
testcase_38 AC 32 ms
6,524 KB
testcase_39 WA -
testcase_40 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const ll MAX = 200000;
ll b[MAX + 1]{};
ll c[MAX + 1]{};

int main() {
    int N;
    cin >> N;
    ll A[N];
    ll sum = 0;
    set<int> s;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        b[A[i]]++;
        s.insert(A[i]);
        sum += A[i];
    }
    
    for (int i = 1; i <= MAX; i++) {
        c[i] = c[i - 1] + b[i]; 
    }
    ll ans = sum * N;
    //cout << ans << "\n";
    for (ll i : s) {
        int t = i;
        if (i == 1) {
            ans -= b[1] * sum;
            continue;
        }
        //cout << "***********\n";
        //cout << i << "\n";
        for (ll k = 1; k < 20000; k++) {
            ll l = i * k - 1;
            ll r = min(MAX, i * (k + 1) - 1);
            if (l > MAX) break;
            //cout << l << " " << r << "\n";
            //cout << c[r + 1] - c[l + 1] << " " << b[i * k] << "\n";
            ll e = (c[r] - c[l]) * k * i * b[i];
            ans -= e;
            // if (e < 0) {
            //     cout << l << " " << r << "\n";
            //     cout << c[r] << " " << c[l] << "\n";
            //     cout << k << " aa\n";
            //     break;
            // }
            //cout << e << "\n";
        }
        //cout << ans << "\n";
    }
    cout << ans << "\n";
    // for (int i = 0; i < 100; i++) {
    //     cout << c[i] << "\n";
    // }
    // cout << "\n";
    // for (int i = 0; i < 10; i++) {
    //     cout << c[i] << " ";
    // }
    return 0;
}
0