結果

問題 No.1233 割り切れない気持ち
ユーザー fumofumofunifumofumofuni
提出日時 2020-09-19 00:09:52
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,628 bytes
コンパイル時間 1,526 ms
コンパイル使用メモリ 167,388 KB
実行使用メモリ 7,884 KB
最終ジャッジ日時 2023-09-04 19:52:31
合計ジャッジ時間 6,874 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
6,220 KB
testcase_01 AC 4 ms
6,184 KB
testcase_02 AC 5 ms
6,156 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 5 ms
6,192 KB
testcase_06 AC 5 ms
6,472 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 RE -
testcase_10 RE -
testcase_11 WA -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 AC 33 ms
7,844 KB
testcase_18 RE -
testcase_19 RE -
testcase_20 AC 35 ms
7,740 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
testcase_36 RE -
testcase_37 AC 5 ms
6,184 KB
testcase_38 RE -
testcase_39 RE -
testcase_40 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll n;cin >> n;
    vector<ll> v(100001),a(n),memo(100001,-1);
    rep(i,n){
        cin >> a[i];
        v[a[i]]++;
    }
    ll sum=0;
    vl cum(100001),cnt(100001);
    rep(i,100000)cum[i+1]+=cum[i]+i*v[i];
    rep(i,100000)cnt[i+1]+=cnt[i]+v[i];
    //rep(i,10)cout<< cum[i] <<" " << cnt[i] <<endl;
    rep(i,n){
        ll p=a[i];
        if(memo[p]!=-1){sum+=memo[p];continue;}
        memo[p]=0;
        for(int j=0;j*p+j<=100000;j++){
            memo[p]+=cum[j*p+p]-cum[j*p]-j*p*(cnt[j*p+p]-cnt[j*p]);
        }
        sum+=memo[p];
        //cout << sum<<endl;
    }
    cout << sum <<endl;
}
0