結果
問題 | No.1262 グラフを作ろう! |
ユーザー | tokusakurai |
提出日時 | 2020-10-16 23:11:07 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 385 ms / 3,000 ms |
コード長 | 1,390 bytes |
コンパイル時間 | 2,113 ms |
コンパイル使用メモリ | 201,732 KB |
実行使用メモリ | 19,168 KB |
最終ジャッジ日時 | 2024-07-20 23:41:15 |
合計ジャッジ時間 | 27,718 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 285 ms
12,160 KB |
testcase_01 | AC | 200 ms
10,112 KB |
testcase_02 | AC | 291 ms
14,496 KB |
testcase_03 | AC | 285 ms
9,600 KB |
testcase_04 | AC | 46 ms
13,056 KB |
testcase_05 | AC | 152 ms
11,616 KB |
testcase_06 | AC | 44 ms
14,720 KB |
testcase_07 | AC | 37 ms
5,760 KB |
testcase_08 | AC | 196 ms
15,276 KB |
testcase_09 | AC | 195 ms
7,552 KB |
testcase_10 | AC | 146 ms
9,004 KB |
testcase_11 | AC | 200 ms
16,384 KB |
testcase_12 | AC | 273 ms
11,392 KB |
testcase_13 | AC | 291 ms
10,040 KB |
testcase_14 | AC | 129 ms
9,472 KB |
testcase_15 | AC | 158 ms
6,656 KB |
testcase_16 | AC | 208 ms
14,624 KB |
testcase_17 | AC | 199 ms
12,800 KB |
testcase_18 | AC | 292 ms
15,756 KB |
testcase_19 | AC | 52 ms
12,012 KB |
testcase_20 | AC | 116 ms
16,084 KB |
testcase_21 | AC | 313 ms
14,592 KB |
testcase_22 | AC | 34 ms
11,136 KB |
testcase_23 | AC | 181 ms
8,064 KB |
testcase_24 | AC | 210 ms
15,232 KB |
testcase_25 | AC | 41 ms
8,448 KB |
testcase_26 | AC | 66 ms
9,584 KB |
testcase_27 | AC | 134 ms
13,896 KB |
testcase_28 | AC | 115 ms
12,328 KB |
testcase_29 | AC | 83 ms
12,916 KB |
testcase_30 | AC | 102 ms
9,856 KB |
testcase_31 | AC | 312 ms
12,720 KB |
testcase_32 | AC | 180 ms
11,136 KB |
testcase_33 | AC | 85 ms
5,760 KB |
testcase_34 | AC | 161 ms
16,248 KB |
testcase_35 | AC | 267 ms
10,240 KB |
testcase_36 | AC | 102 ms
5,632 KB |
testcase_37 | AC | 318 ms
16,000 KB |
testcase_38 | AC | 170 ms
13,184 KB |
testcase_39 | AC | 174 ms
7,680 KB |
testcase_40 | AC | 153 ms
8,832 KB |
testcase_41 | AC | 101 ms
13,952 KB |
testcase_42 | AC | 263 ms
15,804 KB |
testcase_43 | AC | 136 ms
11,776 KB |
testcase_44 | AC | 161 ms
11,248 KB |
testcase_45 | AC | 234 ms
16,512 KB |
testcase_46 | AC | 82 ms
15,488 KB |
testcase_47 | AC | 213 ms
7,424 KB |
testcase_48 | AC | 220 ms
14,592 KB |
testcase_49 | AC | 309 ms
15,468 KB |
testcase_50 | AC | 251 ms
15,820 KB |
testcase_51 | AC | 239 ms
8,704 KB |
testcase_52 | AC | 96 ms
14,752 KB |
testcase_53 | AC | 58 ms
7,168 KB |
testcase_54 | AC | 313 ms
11,648 KB |
testcase_55 | AC | 218 ms
11,132 KB |
testcase_56 | AC | 101 ms
13,568 KB |
testcase_57 | AC | 349 ms
17,744 KB |
testcase_58 | AC | 280 ms
10,624 KB |
testcase_59 | AC | 97 ms
14,080 KB |
testcase_60 | AC | 316 ms
16,820 KB |
testcase_61 | AC | 132 ms
9,088 KB |
testcase_62 | AC | 294 ms
14,208 KB |
testcase_63 | AC | 318 ms
11,008 KB |
testcase_64 | AC | 198 ms
10,576 KB |
testcase_65 | AC | 58 ms
9,520 KB |
testcase_66 | AC | 137 ms
9,560 KB |
testcase_67 | AC | 94 ms
10,752 KB |
testcase_68 | AC | 72 ms
15,360 KB |
testcase_69 | AC | 104 ms
10,236 KB |
testcase_70 | AC | 223 ms
16,840 KB |
testcase_71 | AC | 210 ms
13,572 KB |
testcase_72 | AC | 266 ms
16,768 KB |
testcase_73 | AC | 336 ms
15,404 KB |
testcase_74 | AC | 318 ms
13,052 KB |
testcase_75 | AC | 249 ms
14,208 KB |
testcase_76 | AC | 201 ms
13,164 KB |
testcase_77 | AC | 275 ms
13,664 KB |
testcase_78 | AC | 235 ms
14,544 KB |
testcase_79 | AC | 301 ms
17,612 KB |
testcase_80 | AC | 211 ms
16,896 KB |
testcase_81 | AC | 276 ms
13,440 KB |
testcase_82 | AC | 329 ms
14,464 KB |
testcase_83 | AC | 206 ms
16,224 KB |
testcase_84 | AC | 207 ms
13,444 KB |
testcase_85 | AC | 329 ms
17,716 KB |
testcase_86 | AC | 265 ms
14,336 KB |
testcase_87 | AC | 309 ms
16,424 KB |
testcase_88 | AC | 272 ms
13,312 KB |
testcase_89 | AC | 195 ms
15,488 KB |
testcase_90 | AC | 344 ms
19,072 KB |
testcase_91 | AC | 345 ms
19,168 KB |
testcase_92 | AC | 342 ms
19,072 KB |
testcase_93 | AC | 385 ms
19,072 KB |
testcase_94 | AC | 346 ms
19,072 KB |
testcase_95 | AC | 346 ms
19,152 KB |
ソースコード
#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; }