結果

問題 No.1233 割り切れない気持ち
ユーザー ShibuyapShibuyap
提出日時 2020-09-18 22:02:44
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 76 ms / 3,153 ms
コード長 1,031 bytes
コンパイル時間 1,972 ms
コンパイル使用メモリ 198,956 KB
実行使用メモリ 8,976 KB
最終ジャッジ日時 2023-09-04 21:47:59
合計ジャッジ時間 5,735 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,632 KB
testcase_01 AC 15 ms
7,440 KB
testcase_02 AC 15 ms
7,452 KB
testcase_03 AC 15 ms
7,472 KB
testcase_04 AC 15 ms
7,556 KB
testcase_05 AC 15 ms
7,552 KB
testcase_06 AC 15 ms
7,512 KB
testcase_07 AC 28 ms
7,652 KB
testcase_08 AC 38 ms
7,812 KB
testcase_09 AC 62 ms
8,400 KB
testcase_10 AC 65 ms
8,552 KB
testcase_11 AC 27 ms
7,896 KB
testcase_12 AC 74 ms
8,976 KB
testcase_13 AC 74 ms
8,896 KB
testcase_14 AC 75 ms
8,972 KB
testcase_15 AC 76 ms
8,824 KB
testcase_16 AC 76 ms
8,844 KB
testcase_17 AC 42 ms
8,288 KB
testcase_18 AC 70 ms
8,828 KB
testcase_19 AC 72 ms
7,268 KB
testcase_20 AC 41 ms
8,232 KB
testcase_21 AC 52 ms
8,244 KB
testcase_22 AC 53 ms
8,280 KB
testcase_23 AC 52 ms
8,288 KB
testcase_24 AC 53 ms
8,284 KB
testcase_25 AC 53 ms
8,264 KB
testcase_26 AC 53 ms
8,232 KB
testcase_27 AC 61 ms
8,544 KB
testcase_28 AC 61 ms
8,548 KB
testcase_29 AC 61 ms
8,480 KB
testcase_30 AC 61 ms
8,520 KB
testcase_31 AC 61 ms
8,500 KB
testcase_32 AC 61 ms
8,440 KB
testcase_33 AC 61 ms
8,464 KB
testcase_34 AC 61 ms
8,520 KB
testcase_35 AC 61 ms
8,508 KB
testcase_36 AC 61 ms
8,380 KB
testcase_37 AC 15 ms
7,448 KB
testcase_38 AC 41 ms
8,252 KB
testcase_39 AC 55 ms
8,836 KB
testcase_40 AC 56 ms
8,844 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("YES");}else{puts("NO");}
#define MAX_N 200005
ll f[MAX_N];
ll sum[MAX_N], cnt[MAX_N];
int main() {
    int n; cin >> n;
    int a[n] = {};
    rep(i,n){
        cin >> a[i];
        f[a[i]]++;
    }
    srep(i,1,MAX_N){
        sum[i] = sum[i-1] + f[i] * i;
        cnt[i] = cnt[i-1] + f[i];
    }


    ll ans = 0;

    srep(i,1,200001){  
        ans += sum[i-1] * f[i];
        srep(j,1,MAX_N){
            int ii = i * j;
            int k = i * (j+1) - 1;
            if(ii > 200000)break;
            if(k >= MAX_N) k = MAX_N - 1;
            ll tmp = sum[k] - sum[ii-1] - (cnt[k]-cnt[ii-1]) * j * i;
            // if(tmp > 0) cout << i << ' ' << j << ' ' << tmp << endl;
            ans += tmp * f[i];
        }
    }

    cout << ans << endl;
    return 0;
}
 
 
0