結果

問題 No.1233 割り切れない気持ち
ユーザー mugen_1337mugen_1337
提出日時 2020-09-18 23:01:23
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 55 ms / 3,153 ms
コード長 1,682 bytes
コンパイル時間 1,975 ms
コンパイル使用メモリ 202,172 KB
実行使用メモリ 14,244 KB
最終ジャッジ日時 2023-09-04 21:53:07
合計ジャッジ時間 5,632 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
12,472 KB
testcase_01 AC 31 ms
12,472 KB
testcase_02 AC 30 ms
12,372 KB
testcase_03 AC 30 ms
12,668 KB
testcase_04 AC 32 ms
12,532 KB
testcase_05 AC 31 ms
12,432 KB
testcase_06 AC 31 ms
12,488 KB
testcase_07 AC 36 ms
12,892 KB
testcase_08 AC 41 ms
13,072 KB
testcase_09 AC 49 ms
13,740 KB
testcase_10 AC 51 ms
13,776 KB
testcase_11 AC 35 ms
12,628 KB
testcase_12 AC 53 ms
14,060 KB
testcase_13 AC 54 ms
14,016 KB
testcase_14 AC 55 ms
13,940 KB
testcase_15 AC 55 ms
13,940 KB
testcase_16 AC 53 ms
14,068 KB
testcase_17 AC 43 ms
13,992 KB
testcase_18 AC 49 ms
14,084 KB
testcase_19 AC 51 ms
14,048 KB
testcase_20 AC 43 ms
13,944 KB
testcase_21 AC 46 ms
13,992 KB
testcase_22 AC 46 ms
14,084 KB
testcase_23 AC 46 ms
13,952 KB
testcase_24 AC 46 ms
14,060 KB
testcase_25 AC 45 ms
13,996 KB
testcase_26 AC 46 ms
13,952 KB
testcase_27 AC 48 ms
14,052 KB
testcase_28 AC 47 ms
13,980 KB
testcase_29 AC 47 ms
13,940 KB
testcase_30 AC 48 ms
14,012 KB
testcase_31 AC 48 ms
14,052 KB
testcase_32 AC 49 ms
14,004 KB
testcase_33 AC 48 ms
13,984 KB
testcase_34 AC 48 ms
14,060 KB
testcase_35 AC 49 ms
14,244 KB
testcase_36 AC 47 ms
13,944 KB
testcase_37 AC 30 ms
12,372 KB
testcase_38 AC 43 ms
13,992 KB
testcase_39 AC 46 ms
13,944 KB
testcase_40 AC 46 ms
13,996 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define mod 1000000007
using ll=long long;
const int INF=1000000000;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

struct IOSetup{
    IOSetup(){
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout<<fixed<<setprecision(12);
    }
} iosetup;
 
template<typename T1,typename T2>
ostream &operator<<(ostream &os,const pair<T1,T2>&p){
    os<<p.first<<" "<<p.second;
    return os;
}
 
template<typename T>
ostream &operator<<(ostream &os,const vector<T>&v){
    for(int i=0;i<(int)v.size();i++) os<<v[i]<<(i+1==(int)v.size()?"":" ");
    return os;
}

template<typename T1,typename T2>
istream &operator>>(istream &is,pair<T1,T2>&p){
    is>>p.first>>p.second;
    return is;
}

template<typename T>
istream &operator>>(istream &is,vector<T>&v){
    for(T &x:v)is>>x;
    return is;
}


const int M=400010;

signed main(){
    int n;cin>>n;
    vector<ll> a(n),b(M,0),s1(M+1,0),s2(M+1,0);
    rep(i,n){
        cin>>a[i];
        b[a[i]]++;
    }
    rep(i,M){
        s1[i+1]=s1[i]+b[i];
        s2[i+1]=s2[i]+b[i]*i;
    }

    ll res=0;
    for(int i=1;i<M;i++){
        ll p=0;
        for(int j=i;j<M;j+=i){
            res+=b[i]*((s2[j]-s2[p])-(s1[j]-s1[p])*p);
            p=j;
        }
    }
    cout<<res<<endl;
    return 0;
}
0