結果
問題 | No.1262 グラフを作ろう! |
ユーザー | 👑 hos.lyric |
提出日時 | 2020-10-16 22:00:37 |
言語 | D (dmd 2.106.1) |
結果 |
AC
|
実行時間 | 221 ms / 3,000 ms |
コード長 | 2,055 bytes |
コンパイル時間 | 970 ms |
コンパイル使用メモリ | 121,344 KB |
実行使用メモリ | 58,972 KB |
最終ジャッジ日時 | 2024-06-22 09:27:18 |
合計ジャッジ時間 | 24,667 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 202 ms
55,260 KB |
testcase_01 | AC | 172 ms
36,564 KB |
testcase_02 | AC | 195 ms
54,888 KB |
testcase_03 | AC | 220 ms
56,416 KB |
testcase_04 | AC | 64 ms
15,988 KB |
testcase_05 | AC | 119 ms
25,652 KB |
testcase_06 | AC | 59 ms
15,192 KB |
testcase_07 | AC | 70 ms
17,008 KB |
testcase_08 | AC | 140 ms
35,144 KB |
testcase_09 | AC | 152 ms
37,528 KB |
testcase_10 | AC | 119 ms
25,956 KB |
testcase_11 | AC | 143 ms
35,368 KB |
testcase_12 | AC | 181 ms
41,252 KB |
testcase_13 | AC | 213 ms
56,476 KB |
testcase_14 | AC | 111 ms
26,032 KB |
testcase_15 | AC | 133 ms
35,600 KB |
testcase_16 | AC | 148 ms
36,196 KB |
testcase_17 | AC | 146 ms
35,872 KB |
testcase_18 | AC | 203 ms
55,100 KB |
testcase_19 | AC | 69 ms
16,852 KB |
testcase_20 | AC | 99 ms
24,544 KB |
testcase_21 | AC | 215 ms
56,848 KB |
testcase_22 | AC | 58 ms
15,180 KB |
testcase_23 | AC | 150 ms
36,096 KB |
testcase_24 | AC | 137 ms
36,060 KB |
testcase_25 | AC | 67 ms
16,396 KB |
testcase_26 | AC | 82 ms
20,724 KB |
testcase_27 | AC | 111 ms
25,676 KB |
testcase_28 | AC | 105 ms
24,956 KB |
testcase_29 | AC | 86 ms
21,148 KB |
testcase_30 | AC | 101 ms
24,728 KB |
testcase_31 | AC | 221 ms
56,960 KB |
testcase_32 | AC | 138 ms
35,076 KB |
testcase_33 | AC | 89 ms
24,888 KB |
testcase_34 | AC | 111 ms
25,284 KB |
testcase_35 | AC | 173 ms
41,212 KB |
testcase_36 | AC | 102 ms
25,812 KB |
testcase_37 | AC | 211 ms
56,316 KB |
testcase_38 | AC | 122 ms
33,780 KB |
testcase_39 | AC | 137 ms
35,884 KB |
testcase_40 | AC | 129 ms
33,776 KB |
testcase_41 | AC | 85 ms
21,868 KB |
testcase_42 | AC | 159 ms
39,580 KB |
testcase_43 | AC | 110 ms
24,196 KB |
testcase_44 | AC | 128 ms
33,696 KB |
testcase_45 | AC | 146 ms
37,476 KB |
testcase_46 | AC | 82 ms
20,724 KB |
testcase_47 | AC | 160 ms
39,472 KB |
testcase_48 | AC | 142 ms
37,080 KB |
testcase_49 | AC | 211 ms
55,996 KB |
testcase_50 | AC | 154 ms
38,644 KB |
testcase_51 | AC | 161 ms
39,080 KB |
testcase_52 | AC | 82 ms
21,612 KB |
testcase_53 | AC | 71 ms
18,220 KB |
testcase_54 | AC | 204 ms
56,780 KB |
testcase_55 | AC | 151 ms
37,320 KB |
testcase_56 | AC | 88 ms
21,916 KB |
testcase_57 | AC | 206 ms
56,896 KB |
testcase_58 | AC | 195 ms
54,856 KB |
testcase_59 | AC | 88 ms
21,660 KB |
testcase_60 | AC | 205 ms
56,004 KB |
testcase_61 | AC | 102 ms
24,432 KB |
testcase_62 | AC | 191 ms
55,100 KB |
testcase_63 | AC | 212 ms
57,180 KB |
testcase_64 | AC | 146 ms
36,112 KB |
testcase_65 | AC | 68 ms
17,744 KB |
testcase_66 | AC | 103 ms
24,832 KB |
testcase_67 | AC | 86 ms
22,152 KB |
testcase_68 | AC | 68 ms
17,624 KB |
testcase_69 | AC | 93 ms
24,580 KB |
testcase_70 | AC | 139 ms
36,668 KB |
testcase_71 | AC | 142 ms
36,372 KB |
testcase_72 | AC | 154 ms
39,292 KB |
testcase_73 | AC | 206 ms
57,484 KB |
testcase_74 | AC | 200 ms
55,736 KB |
testcase_75 | AC | 152 ms
38,688 KB |
testcase_76 | AC | 132 ms
35,840 KB |
testcase_77 | AC | 165 ms
40,816 KB |
testcase_78 | AC | 154 ms
37,808 KB |
testcase_79 | AC | 190 ms
54,908 KB |
testcase_80 | AC | 143 ms
35,800 KB |
testcase_81 | AC | 163 ms
40,680 KB |
testcase_82 | AC | 204 ms
57,368 KB |
testcase_83 | AC | 139 ms
35,604 KB |
testcase_84 | AC | 132 ms
36,156 KB |
testcase_85 | AC | 200 ms
56,644 KB |
testcase_86 | AC | 167 ms
39,892 KB |
testcase_87 | AC | 190 ms
55,652 KB |
testcase_88 | AC | 169 ms
40,644 KB |
testcase_89 | AC | 128 ms
35,004 KB |
testcase_90 | AC | 207 ms
57,480 KB |
testcase_91 | AC | 212 ms
57,480 KB |
testcase_92 | AC | 213 ms
57,604 KB |
testcase_93 | AC | 221 ms
58,972 KB |
testcase_94 | AC | 210 ms
57,480 KB |
testcase_95 | AC | 208 ms
57,500 KB |
ソースコード
import std.conv, std.functional, std.range, std.stdio, std.string; import std.algorithm, std.array, std.bigint, std.bitmanip, std.complex, std.container, std.math, std.mathspecial, std.numeric, std.regex, std.typecons; import core.bitop; class EOFException : Throwable { this() { super("EOF"); } } string[] tokens; string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; } int readInt() { return readToken.to!int; } long readLong() { return readToken.to!long; } real readReal() { return readToken.to!real; } bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } } bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } } int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; } int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); } int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); } enum LIM = 10^^6 + 10; void main() { auto lpf = iota(LIM).array; foreach (p; 2 .. LIM) { if (lpf[p] == p) { for (int n = 2 * p; n < LIM; n += p) { chmin(lpf[n], p); } } } auto fs = new long[LIM]; fs[1] = 1; foreach (n; 2 .. LIM) { const p = lpf[n]; int e; int nn = n; do { ++e; nn /= p; } while (nn % p == 0); if (nn == 1) { fs[n] = 1L * n / p * (1L * (p - 1) * e + p); } else { fs[n] = fs[n / nn] * fs[nn]; } } debug { writeln("fs = ", fs[0 .. 31]); } try { for (; ; ) { const N = readInt(); const M = readInt(); auto A = new int[M]; foreach (i; 0 .. M) { A[i] = readInt(); } long ans; foreach (i; 0 .. M) { ans += fs[A[i]] - A[i]; } writeln(ans); } } catch (EOFException e) { } }