結果

問題 No.1233 割り切れない気持ち
ユーザー ゆきのんゆきのん
提出日時 2020-09-21 07:34:57
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 174 ms / 3,153 ms
コード長 1,237 bytes
コンパイル時間 2,201 ms
コンパイル使用メモリ 167,976 KB
実行使用メモリ 45,928 KB
最終ジャッジ日時 2023-09-06 16:57:05
合計ジャッジ時間 7,030 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
43,808 KB
testcase_01 AC 20 ms
44,132 KB
testcase_02 AC 37 ms
44,216 KB
testcase_03 AC 60 ms
44,240 KB
testcase_04 AC 54 ms
44,068 KB
testcase_05 AC 39 ms
44,200 KB
testcase_06 AC 41 ms
44,152 KB
testcase_07 AC 98 ms
44,516 KB
testcase_08 AC 108 ms
44,596 KB
testcase_09 AC 131 ms
45,124 KB
testcase_10 AC 133 ms
45,564 KB
testcase_11 AC 89 ms
44,376 KB
testcase_12 AC 143 ms
45,428 KB
testcase_13 AC 143 ms
45,392 KB
testcase_14 AC 143 ms
45,392 KB
testcase_15 AC 144 ms
45,392 KB
testcase_16 AC 146 ms
45,508 KB
testcase_17 AC 49 ms
45,452 KB
testcase_18 AC 174 ms
45,452 KB
testcase_19 AC 77 ms
45,404 KB
testcase_20 AC 51 ms
45,428 KB
testcase_21 AC 62 ms
45,396 KB
testcase_22 AC 61 ms
45,472 KB
testcase_23 AC 61 ms
45,516 KB
testcase_24 AC 61 ms
45,432 KB
testcase_25 AC 60 ms
45,444 KB
testcase_26 AC 61 ms
45,928 KB
testcase_27 AC 68 ms
45,468 KB
testcase_28 AC 68 ms
45,452 KB
testcase_29 AC 68 ms
45,376 KB
testcase_30 AC 67 ms
45,392 KB
testcase_31 AC 68 ms
45,468 KB
testcase_32 AC 67 ms
45,388 KB
testcase_33 AC 68 ms
45,516 KB
testcase_34 AC 68 ms
45,392 KB
testcase_35 AC 68 ms
45,396 KB
testcase_36 AC 67 ms
45,428 KB
testcase_37 AC 19 ms
44,144 KB
testcase_38 AC 50 ms
45,456 KB
testcase_39 AC 118 ms
45,388 KB
testcase_40 AC 115 ms
45,472 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
const ll MOD=1000000007;
const ll LINF=1ll<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0,1,-1,1,-1};
int dy[]={0,1,0,-1,1,-1,-1,1};


int main(){
    int n;cin >> n;
    vector<ll> a(n);
    vector<ll> c(1<<20,0),x(1<<20 + 1,0),y(1<<20 + 1, 0);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        c[a[i]]++;
    }
    for (int i = 0; i < 1<<20; i++) {
        x[i+1] = x[i] + c[i];
        y[i+1] = y[i] + i * c[i];
    }
    ll ans = 0;
    for (int i = 1; i < 1<<20; i++) {
        if(c[i]){
            for (int j = i; j < 1<<20; j+=i) {
                ll t = j / i - 1;
                ans += c[i] * ((y[j] - y[j-i]) - (x[j] - x[j-i]) * i * t);
            }
        }
    }
    cout << ans << endl;
    return 0;
}
0