結果

問題 No.1262 グラフを作ろう!
ユーザー chocoruskchocorusk
提出日時 2020-10-16 22:23:49
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 377 ms / 3,000 ms
コード長 1,556 bytes
コンパイル時間 1,271 ms
コンパイル使用メモリ 127,676 KB
実行使用メモリ 19,300 KB
最終ジャッジ日時 2023-09-28 03:45:29
合計ジャッジ時間 31,517 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 286 ms
19,012 KB
testcase_01 AC 195 ms
19,004 KB
testcase_02 AC 311 ms
19,052 KB
testcase_03 AC 257 ms
19,000 KB
testcase_04 AC 85 ms
19,048 KB
testcase_05 AC 175 ms
18,960 KB
testcase_06 AC 89 ms
19,160 KB
testcase_07 AC 44 ms
19,164 KB
testcase_08 AC 237 ms
19,016 KB
testcase_09 AC 177 ms
19,072 KB
testcase_10 AC 152 ms
19,164 KB
testcase_11 AC 253 ms
19,080 KB
testcase_12 AC 279 ms
19,012 KB
testcase_13 AC 280 ms
19,048 KB
testcase_14 AC 146 ms
18,968 KB
testcase_15 AC 149 ms
18,964 KB
testcase_16 AC 247 ms
18,960 KB
testcase_17 AC 224 ms
18,968 KB
testcase_18 AC 330 ms
19,056 KB
testcase_19 AC 86 ms
19,016 KB
testcase_20 AC 180 ms
19,020 KB
testcase_21 AC 346 ms
19,240 KB
testcase_22 AC 64 ms
19,048 KB
testcase_23 AC 178 ms
19,160 KB
testcase_24 AC 242 ms
19,112 KB
testcase_25 AC 57 ms
18,996 KB
testcase_26 AC 88 ms
19,028 KB
testcase_27 AC 165 ms
18,964 KB
testcase_28 AC 145 ms
19,000 KB
testcase_29 AC 118 ms
18,996 KB
testcase_30 AC 116 ms
18,952 KB
testcase_31 AC 304 ms
19,012 KB
testcase_32 AC 192 ms
19,096 KB
testcase_33 AC 86 ms
19,184 KB
testcase_34 AC 215 ms
19,300 KB
testcase_35 AC 252 ms
19,188 KB
testcase_36 AC 97 ms
19,164 KB
testcase_37 AC 350 ms
18,984 KB
testcase_38 AC 188 ms
18,984 KB
testcase_39 AC 162 ms
19,112 KB
testcase_40 AC 158 ms
19,044 KB
testcase_41 AC 145 ms
18,996 KB
testcase_42 AC 288 ms
19,028 KB
testcase_43 AC 157 ms
18,968 KB
testcase_44 AC 171 ms
19,012 KB
testcase_45 AC 291 ms
18,960 KB
testcase_46 AC 133 ms
19,000 KB
testcase_47 AC 194 ms
19,012 KB
testcase_48 AC 282 ms
19,060 KB
testcase_49 AC 362 ms
18,956 KB
testcase_50 AC 295 ms
19,160 KB
testcase_51 AC 212 ms
18,988 KB
testcase_52 AC 145 ms
19,292 KB
testcase_53 AC 61 ms
19,000 KB
testcase_54 AC 312 ms
18,992 KB
testcase_55 AC 236 ms
18,952 KB
testcase_56 AC 129 ms
19,012 KB
testcase_57 AC 358 ms
19,028 KB
testcase_58 AC 254 ms
18,992 KB
testcase_59 AC 133 ms
19,048 KB
testcase_60 AC 347 ms
19,092 KB
testcase_61 AC 140 ms
18,992 KB
testcase_62 AC 294 ms
19,112 KB
testcase_63 AC 286 ms
19,044 KB
testcase_64 AC 193 ms
19,240 KB
testcase_65 AC 71 ms
18,992 KB
testcase_66 AC 140 ms
18,956 KB
testcase_67 AC 113 ms
19,076 KB
testcase_68 AC 123 ms
18,964 KB
testcase_69 AC 129 ms
18,968 KB
testcase_70 AC 266 ms
18,968 KB
testcase_71 AC 215 ms
18,956 KB
testcase_72 AC 284 ms
18,992 KB
testcase_73 AC 318 ms
19,012 KB
testcase_74 AC 283 ms
19,048 KB
testcase_75 AC 253 ms
19,164 KB
testcase_76 AC 199 ms
19,076 KB
testcase_77 AC 262 ms
18,960 KB
testcase_78 AC 237 ms
18,988 KB
testcase_79 AC 321 ms
19,080 KB
testcase_80 AC 241 ms
19,012 KB
testcase_81 AC 257 ms
19,000 KB
testcase_82 AC 304 ms
19,076 KB
testcase_83 AC 232 ms
18,992 KB
testcase_84 AC 205 ms
19,096 KB
testcase_85 AC 350 ms
19,092 KB
testcase_86 AC 258 ms
19,288 KB
testcase_87 AC 306 ms
18,952 KB
testcase_88 AC 262 ms
19,080 KB
testcase_89 AC 218 ms
18,968 KB
testcase_90 AC 351 ms
19,016 KB
testcase_91 AC 354 ms
19,000 KB
testcase_92 AC 352 ms
19,296 KB
testcase_93 AC 377 ms
19,016 KB
testcase_94 AC 351 ms
19,080 KB
testcase_95 AC 354 ms
18,964 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#define popcount __builtin_popcount
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll MOD=1e9+7;
ll powmod(ll a, ll k){
    ll ap=a, ans=1;
    while(k){
        if(k&1){
            ans*=ap;
            ans%=MOD;
        }
        ap=ap*ap;
        ap%=MOD;
        k>>=1;
    }
    return ans;
}
ll inv(ll a){
    return powmod(a, MOD-2);
}
ll f[2000010], invf[2000010];
void fac(int n){
    f[0]=1;
    for(ll i=1; i<=n; i++) f[i]=f[i-1]*i%MOD;
    invf[n]=inv(f[n]);
    for(ll i=n-1; i>=0; i--) invf[i]=invf[i+1]*(i+1)%MOD;
}
ll comb(int x, int y){
    if(!(0<=y && y<=x)) return 0;
    return f[x]*invf[y]%MOD*invf[x-y]%MOD;
}
int main()
{
    int n, m; cin>>n>>m;
    ll c[1000010]={};
    ll ans=0;
    for(int i=0; i<m; i++){
        int a; cin>>a; c[a]++;
        ans-=a;
    }
    ll x[1000010]={};
    for(int d=1; d<=n; d++){
        for(int i=d; i<=n; i+=d){
            x[d]+=c[i]*(i/d);
        }
    }
    for(int i=n; i>=1; i--){
        for(int j=2*i; j<=n; j+=i){
            x[i]-=x[j];
        }
        ans+=x[i]*i;
    }
    cout<<ans<<endl;
    return 0;
}
0