結果

問題 No.1233 割り切れない気持ち
ユーザー CuriousFairy315CuriousFairy315
提出日時 2019-08-01 21:02:23
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 69 ms / 3,153 ms
コード長 581 bytes
コンパイル時間 534 ms
コンパイル使用メモリ 52,216 KB
実行使用メモリ 8,304 KB
最終ジャッジ日時 2023-09-04 21:41:45
合計ジャッジ時間 4,174 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
6,736 KB
testcase_01 AC 7 ms
6,564 KB
testcase_02 AC 7 ms
6,588 KB
testcase_03 AC 8 ms
6,496 KB
testcase_04 AC 7 ms
6,496 KB
testcase_05 AC 7 ms
6,448 KB
testcase_06 AC 7 ms
6,744 KB
testcase_07 AC 21 ms
6,908 KB
testcase_08 AC 31 ms
7,196 KB
testcase_09 AC 57 ms
7,788 KB
testcase_10 AC 59 ms
8,000 KB
testcase_11 AC 20 ms
6,844 KB
testcase_12 AC 66 ms
8,060 KB
testcase_13 AC 67 ms
8,004 KB
testcase_14 AC 69 ms
8,076 KB
testcase_15 AC 67 ms
8,048 KB
testcase_16 AC 67 ms
8,040 KB
testcase_17 AC 35 ms
8,008 KB
testcase_18 AC 60 ms
8,060 KB
testcase_19 AC 67 ms
8,292 KB
testcase_20 AC 34 ms
8,104 KB
testcase_21 AC 46 ms
8,064 KB
testcase_22 AC 45 ms
7,988 KB
testcase_23 AC 45 ms
8,116 KB
testcase_24 AC 46 ms
8,052 KB
testcase_25 AC 46 ms
8,088 KB
testcase_26 AC 46 ms
8,008 KB
testcase_27 AC 54 ms
8,124 KB
testcase_28 AC 53 ms
8,040 KB
testcase_29 AC 53 ms
8,060 KB
testcase_30 AC 55 ms
8,008 KB
testcase_31 AC 54 ms
8,152 KB
testcase_32 AC 54 ms
8,104 KB
testcase_33 AC 54 ms
8,004 KB
testcase_34 AC 54 ms
8,048 KB
testcase_35 AC 54 ms
8,100 KB
testcase_36 AC 54 ms
8,304 KB
testcase_37 AC 8 ms
6,480 KB
testcase_38 AC 35 ms
8,036 KB
testcase_39 AC 49 ms
8,004 KB
testcase_40 AC 48 ms
8,120 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
using namespace std;

const int MAX = 200001;
int main() {
    int N;
    long A[MAX], cumsum[MAX], divide[MAX];
    for (int i = 0;i < MAX;++ i) cumsum[i] = divide[i] = 0;
    long ans = 0;
    cin >> N;
    for (int i = 0;i < N;++ i) {
        cin >> A[i];
        ++ cumsum[A[i]];
        ans += A[i];
    }
    ans *= N;
    for (int i = MAX - 1;i > 0;-- i) cumsum[i - 1] += cumsum[i];
    for (int i = 1;i < MAX;++ i) for(int j = i;j < MAX;j += i) divide[i] += cumsum[j];
    for (int i = 0;i < N;++ i) ans -= divide[A[i]] * A[i];
    cout << ans << endl;
}
0