結果

問題 No.1262 グラフを作ろう!
ユーザー tokusakuraitokusakurai
提出日時 2020-10-16 23:11:07
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 317 ms / 3,000 ms
コード長 1,390 bytes
コンパイル時間 3,164 ms
コンパイル使用メモリ 197,956 KB
実行使用メモリ 19,220 KB
最終ジャッジ日時 2023-09-28 05:10:16
合計ジャッジ時間 24,938 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 239 ms
12,324 KB
testcase_01 AC 169 ms
10,216 KB
testcase_02 AC 263 ms
14,224 KB
testcase_03 AC 240 ms
9,536 KB
testcase_04 AC 41 ms
12,900 KB
testcase_05 AC 127 ms
11,500 KB
testcase_06 AC 39 ms
14,772 KB
testcase_07 AC 30 ms
5,688 KB
testcase_08 AC 166 ms
15,176 KB
testcase_09 AC 163 ms
7,432 KB
testcase_10 AC 132 ms
8,996 KB
testcase_11 AC 174 ms
16,228 KB
testcase_12 AC 221 ms
11,232 KB
testcase_13 AC 242 ms
9,916 KB
testcase_14 AC 106 ms
9,288 KB
testcase_15 AC 136 ms
6,472 KB
testcase_16 AC 176 ms
14,640 KB
testcase_17 AC 165 ms
12,604 KB
testcase_18 AC 248 ms
15,548 KB
testcase_19 AC 45 ms
11,888 KB
testcase_20 AC 101 ms
15,920 KB
testcase_21 AC 271 ms
14,528 KB
testcase_22 AC 29 ms
10,972 KB
testcase_23 AC 153 ms
8,096 KB
testcase_24 AC 191 ms
15,048 KB
testcase_25 AC 35 ms
8,352 KB
testcase_26 AC 62 ms
9,568 KB
testcase_27 AC 120 ms
13,848 KB
testcase_28 AC 97 ms
12,176 KB
testcase_29 AC 77 ms
12,756 KB
testcase_30 AC 96 ms
9,644 KB
testcase_31 AC 266 ms
12,828 KB
testcase_32 AC 150 ms
11,052 KB
testcase_33 AC 73 ms
5,576 KB
testcase_34 AC 137 ms
16,064 KB
testcase_35 AC 218 ms
10,044 KB
testcase_36 AC 83 ms
5,648 KB
testcase_37 AC 262 ms
15,884 KB
testcase_38 AC 142 ms
12,992 KB
testcase_39 AC 148 ms
7,580 KB
testcase_40 AC 127 ms
8,776 KB
testcase_41 AC 87 ms
13,788 KB
testcase_42 AC 231 ms
15,628 KB
testcase_43 AC 114 ms
11,612 KB
testcase_44 AC 136 ms
11,016 KB
testcase_45 AC 202 ms
16,388 KB
testcase_46 AC 71 ms
15,460 KB
testcase_47 AC 178 ms
7,204 KB
testcase_48 AC 183 ms
14,480 KB
testcase_49 AC 256 ms
15,328 KB
testcase_50 AC 210 ms
15,648 KB
testcase_51 AC 206 ms
8,720 KB
testcase_52 AC 84 ms
14,960 KB
testcase_53 AC 48 ms
7,116 KB
testcase_54 AC 262 ms
11,724 KB
testcase_55 AC 181 ms
11,088 KB
testcase_56 AC 82 ms
13,384 KB
testcase_57 AC 274 ms
17,680 KB
testcase_58 AC 232 ms
10,460 KB
testcase_59 AC 83 ms
13,948 KB
testcase_60 AC 263 ms
16,620 KB
testcase_61 AC 111 ms
8,860 KB
testcase_62 AC 245 ms
14,136 KB
testcase_63 AC 261 ms
10,940 KB
testcase_64 AC 165 ms
10,656 KB
testcase_65 AC 49 ms
9,412 KB
testcase_66 AC 118 ms
9,656 KB
testcase_67 AC 78 ms
10,516 KB
testcase_68 AC 63 ms
15,380 KB
testcase_69 AC 85 ms
10,436 KB
testcase_70 AC 184 ms
16,560 KB
testcase_71 AC 176 ms
13,496 KB
testcase_72 AC 223 ms
16,952 KB
testcase_73 AC 275 ms
15,568 KB
testcase_74 AC 250 ms
12,944 KB
testcase_75 AC 211 ms
14,204 KB
testcase_76 AC 166 ms
13,196 KB
testcase_77 AC 239 ms
13,440 KB
testcase_78 AC 194 ms
14,440 KB
testcase_79 AC 250 ms
17,480 KB
testcase_80 AC 177 ms
16,848 KB
testcase_81 AC 225 ms
13,224 KB
testcase_82 AC 276 ms
14,648 KB
testcase_83 AC 181 ms
16,168 KB
testcase_84 AC 172 ms
13,480 KB
testcase_85 AC 273 ms
17,596 KB
testcase_86 AC 222 ms
14,148 KB
testcase_87 AC 258 ms
16,352 KB
testcase_88 AC 233 ms
13,068 KB
testcase_89 AC 164 ms
15,588 KB
testcase_90 AC 291 ms
18,912 KB
testcase_91 AC 298 ms
18,880 KB
testcase_92 AC 294 ms
18,872 KB
testcase_93 AC 317 ms
18,908 KB
testcase_94 AC 284 ms
19,220 KB
testcase_95 AC 284 ms
18,960 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int MOD = 1000000007;
//const int MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const double pi = acos(-1.0);
const double EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

int main(){
    int N, M;
    cin >> N >> M;
    int A[M];
    rep(i, M) cin >> A[i];

    int p[N+1];
    fill(p, p+N+1, -1);
    rep2(i, 2, N+1){
        if(p[i] != -1) continue;
        for(int j = i; j <= N; j += i){
            if(p[j] == -1) p[j] = i;
        }
    }
    ll dp[N+1];
    dp[1] = 1;
    rep2(i, 2, N){
        int j = p[i], k = 1, tmp = i;
        while(tmp%j == 0) tmp /= j, k *= j;
        dp[i] = (k-k/j)*dp[i/k]+j*dp[i/j];
    }

    ll ans = 0;
    rep(i, M){
        ans += dp[A[i]]-A[i];
    }
    cout << ans << endl;
}
0