結果

問題 No.1233 割り切れない気持ち
ユーザー carrot46carrot46
提出日時 2020-09-18 22:52:53
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 67 ms / 3,153 ms
コード長 1,284 bytes
コンパイル時間 1,583 ms
コンパイル使用メモリ 166,624 KB
実行使用メモリ 6,520 KB
最終ジャッジ日時 2023-09-04 21:51:51
合計ジャッジ時間 4,962 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
4,588 KB
testcase_01 AC 3 ms
4,636 KB
testcase_02 AC 4 ms
4,752 KB
testcase_03 AC 3 ms
4,936 KB
testcase_04 AC 5 ms
4,644 KB
testcase_05 AC 4 ms
4,592 KB
testcase_06 AC 4 ms
4,688 KB
testcase_07 AC 19 ms
4,884 KB
testcase_08 AC 29 ms
5,116 KB
testcase_09 AC 53 ms
6,004 KB
testcase_10 AC 57 ms
5,944 KB
testcase_11 AC 17 ms
4,948 KB
testcase_12 AC 66 ms
6,284 KB
testcase_13 AC 65 ms
6,304 KB
testcase_14 AC 66 ms
6,236 KB
testcase_15 AC 67 ms
6,472 KB
testcase_16 AC 66 ms
6,276 KB
testcase_17 AC 32 ms
6,336 KB
testcase_18 AC 62 ms
6,168 KB
testcase_19 AC 62 ms
6,280 KB
testcase_20 AC 32 ms
6,172 KB
testcase_21 AC 43 ms
6,300 KB
testcase_22 AC 43 ms
6,224 KB
testcase_23 AC 43 ms
6,172 KB
testcase_24 AC 43 ms
6,520 KB
testcase_25 AC 43 ms
6,348 KB
testcase_26 AC 44 ms
6,272 KB
testcase_27 AC 51 ms
6,236 KB
testcase_28 AC 51 ms
6,172 KB
testcase_29 AC 51 ms
6,240 KB
testcase_30 AC 51 ms
6,308 KB
testcase_31 AC 51 ms
6,212 KB
testcase_32 AC 51 ms
6,336 KB
testcase_33 AC 51 ms
6,336 KB
testcase_34 AC 51 ms
6,164 KB
testcase_35 AC 51 ms
6,204 KB
testcase_36 AC 51 ms
6,352 KB
testcase_37 AC 4 ms
4,684 KB
testcase_38 AC 32 ms
6,216 KB
testcase_39 AC 47 ms
6,208 KB
testcase_40 AC 47 ms
6,204 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
//#include <chrono>
//#pragma GCC optimize("Ofast")
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,Q,K,A,B;
string S;
typedef pair<ll, ll> P;
const ll INF = (1LL<<60);

template<class T> bool chmin(T &a, const T &b){
    if(a > b) {a = b; return true;}
    else return false;
}
template<class T> bool chmax(T &a, const T &b){
    if(a < b) {a = b; return true;}
    else return false;
}

int main() {
    cin>>N;
    const int max_A = (int)2e+5;
    vec a(N), num(max_A + 1, 0);
    rep(i, N){
        cin>>a[i];
        ++num[a[i]];
    }
    rep(i, max_A) num[i + 1] += num[i];
    ll res(0), sum = accumulate(ALL(a), 0LL);
    rep(i, max_A){
        ll now = i + 1;
        if(num[now] - num[now - 1] > 0){
            ll temp(sum);
            for(ll j = now - 1; j <= max_A; j += now){
                temp -= now * (N - num[j]);
            }
            //cout<<temp<<endl;
            res += (num[now] - num[now - 1]) * temp;
        }
    }
    cout<<res<<endl;
}
0