結果

問題 No.1233 割り切れない気持ち
ユーザー ゆきのんゆきのん
提出日時 2020-09-21 07:33:20
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,237 bytes
コンパイル時間 1,518 ms
コンパイル使用メモリ 166,752 KB
実行使用メモリ 15,000 KB
最終ジャッジ日時 2023-09-06 16:56:56
合計ジャッジ時間 5,451 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 9 ms
13,244 KB
testcase_01 AC 7 ms
13,148 KB
testcase_02 AC 10 ms
13,208 KB
testcase_03 AC 14 ms
13,244 KB
testcase_04 AC 14 ms
13,188 KB
testcase_05 AC 11 ms
13,148 KB
testcase_06 AC 12 ms
13,152 KB
testcase_07 AC 31 ms
13,780 KB
testcase_08 AC 41 ms
13,944 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 29 ms
13,716 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 35 ms
14,812 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 37 ms
14,724 KB
testcase_21 AC 48 ms
14,812 KB
testcase_22 AC 48 ms
14,836 KB
testcase_23 AC 47 ms
14,828 KB
testcase_24 AC 47 ms
14,872 KB
testcase_25 AC 47 ms
14,812 KB
testcase_26 AC 47 ms
14,740 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 AC 8 ms
13,408 KB
testcase_38 AC 36 ms
14,728 KB
testcase_39 WA -
testcase_40 WA -
権限があれば一括ダウンロードができます

ソースコード

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<<18,0),x(1<<18 + 1,0),y(1<<18 + 1, 0);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        c[a[i]]++;
    }
    for (int i = 0; i < 1<<18; 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<<18; i++) {
        if(c[i]){
            for (int j = i; j < 1<<18; 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