結果
問題 | No.854 公平なりんご分配 |
ユーザー | bal4u |
提出日時 | 2019-07-27 11:17:10 |
言語 | C (gcc 12.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,579 bytes |
コンパイル時間 | 338 ms |
コンパイル使用メモリ | 33,536 KB |
実行使用メモリ | 120,572 KB |
最終ジャッジ日時 | 2024-07-02 10:49:18 |
合計ジャッジ時間 | 5,313 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
6,812 KB |
testcase_01 | AC | 1 ms
6,940 KB |
testcase_02 | AC | 1 ms
6,944 KB |
testcase_03 | AC | 1 ms
6,944 KB |
testcase_04 | AC | 1 ms
6,944 KB |
testcase_05 | AC | 1 ms
6,944 KB |
testcase_06 | AC | 1 ms
6,940 KB |
testcase_07 | AC | 1 ms
6,944 KB |
testcase_08 | AC | 1 ms
6,944 KB |
testcase_09 | AC | 1 ms
6,940 KB |
testcase_10 | AC | 1 ms
6,944 KB |
testcase_11 | AC | 1 ms
6,944 KB |
testcase_12 | AC | 2 ms
9,868 KB |
testcase_13 | AC | 3 ms
9,872 KB |
testcase_14 | AC | 1 ms
6,940 KB |
testcase_15 | AC | 2 ms
7,816 KB |
testcase_16 | AC | 3 ms
11,896 KB |
testcase_17 | AC | 2 ms
11,900 KB |
testcase_18 | AC | 2 ms
9,852 KB |
testcase_19 | AC | 2 ms
9,860 KB |
testcase_20 | AC | 2 ms
7,952 KB |
testcase_21 | AC | 2 ms
9,848 KB |
testcase_22 | AC | 10 ms
44,920 KB |
testcase_23 | AC | 2 ms
5,376 KB |
testcase_24 | AC | 2 ms
5,376 KB |
testcase_25 | AC | 2 ms
5,376 KB |
testcase_26 | AC | 2 ms
5,376 KB |
testcase_27 | AC | 2 ms
5,376 KB |
testcase_28 | AC | 2 ms
5,376 KB |
testcase_29 | AC | 1 ms
5,376 KB |
testcase_30 | AC | 2 ms
5,376 KB |
testcase_31 | AC | 2 ms
5,376 KB |
testcase_32 | AC | 21 ms
22,784 KB |
testcase_33 | AC | 20 ms
49,168 KB |
testcase_34 | AC | 33 ms
30,464 KB |
testcase_35 | AC | 27 ms
56,024 KB |
testcase_36 | AC | 12 ms
5,376 KB |
testcase_37 | AC | 25 ms
68,476 KB |
testcase_38 | AC | 22 ms
68,092 KB |
testcase_39 | AC | 40 ms
74,452 KB |
testcase_40 | AC | 23 ms
65,020 KB |
testcase_41 | AC | 27 ms
68,604 KB |
testcase_42 | AC | 33 ms
74,252 KB |
testcase_43 | AC | 32 ms
69,336 KB |
testcase_44 | AC | 36 ms
72,564 KB |
testcase_45 | AC | 27 ms
63,000 KB |
testcase_46 | AC | 40 ms
71,048 KB |
testcase_47 | AC | 25 ms
67,532 KB |
testcase_48 | AC | 32 ms
73,592 KB |
testcase_49 | AC | 32 ms
73,852 KB |
testcase_50 | AC | 23 ms
69,608 KB |
testcase_51 | AC | 39 ms
72,616 KB |
testcase_52 | WA | - |
testcase_53 | WA | - |
testcase_54 | WA | - |
testcase_55 | WA | - |
testcase_56 | WA | - |
testcase_57 | WA | - |
testcase_58 | WA | - |
testcase_59 | WA | - |
testcase_60 | WA | - |
testcase_61 | WA | - |
testcase_62 | WA | - |
testcase_63 | WA | - |
testcase_64 | WA | - |
testcase_65 | WA | - |
testcase_66 | WA | - |
testcase_67 | WA | - |
testcase_68 | WA | - |
testcase_69 | WA | - |
testcase_70 | WA | - |
testcase_71 | WA | - |
testcase_72 | WA | - |
testcase_73 | WA | - |
testcase_74 | WA | - |
testcase_75 | WA | - |
testcase_76 | WA | - |
testcase_77 | WA | - |
testcase_78 | WA | - |
testcase_79 | WA | - |
testcase_80 | WA | - |
testcase_81 | WA | - |
testcase_82 | WA | - |
testcase_83 | AC | 51 ms
119,564 KB |
testcase_84 | AC | 51 ms
119,604 KB |
testcase_85 | AC | 21 ms
6,940 KB |
testcase_86 | AC | 7 ms
6,944 KB |
testcase_87 | WA | - |
testcase_88 | WA | - |
testcase_89 | WA | - |
testcase_90 | WA | - |
testcase_91 | WA | - |
testcase_92 | AC | 84 ms
119,740 KB |
testcase_93 | AC | 84 ms
119,908 KB |
コンパイルメッセージ
main.c: In function 'in': main.c:9:14: warning: implicit declaration of function 'getchar_unlocked' [-Wimplicit-function-declaration] 9 | #define gc() getchar_unlocked() | ^~~~~~~~~~~~~~~~ main.c:17:24: note: in expansion of macro 'gc' 17 | int n = 0, c = gc(); | ^~ main.c: In function 'outs': main.c:10:15: warning: implicit declaration of function 'putchar_unlocked' [-Wimplicit-function-declaration] 10 | #define pc(c) putchar_unlocked(c) | ^~~~~~~~~~~~~~~~ main.c:22:33: note: in expansion of macro 'pc' 22 | void outs(char *s) { while (*s) pc(*s++); pc('\n'); } | ^~
ソースコード
// yukicoder: No.854 公平なりんご分配 // 2019.7.27 bal4u #include <stdio.h> #include <string.h> #include <math.h> #if 1 #define gc() getchar_unlocked() #define pc(c) putchar_unlocked(c) #else #define gc() getchar() #define pc(c) putchar(c) #endif int in() { // 非負整数の入力 int n = 0, c = gc(); do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0'); return n; } void outs(char *s) { while (*s) pc(*s++); pc('\n'); } #define MAX 100005 #define SIZE 14 #define TBL 305 int id[2003]; int factor[50], power[50], sz; int ptbl[TBL] = {0, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997,1009,1013, 1019,1021,1031,1033,1039,1049,1051,1061,1063,1069, 1087,1091,1093,1097,1103,1109,1117,1123,1129,1151, 1153,1163,1171,1181,1187,1193,1201,1213,1217,1223, 1229,1231,1237,1249,1259,1277,1279,1283,1289,1291, 1297,1301,1303,1307,1319,1321,1327,1361,1367,1373, 1381,1399,1409,1423,1427,1429,1433,1439,1447,1451, 1453,1459,1471,1481,1483,1487,1489,1493,1499,1511, 1523,1531,1543,1549,1553,1559,1567,1571,1579,1583, 1597,1601,1607,1609,1613,1619,1621,1627,1637,1657, 1663,1667,1669,1693,1697,1699,1709,1721,1723,1733, 1741,1747,1753,1759,1777,1783,1787,1789,1801,1811, 1823,1831,1847,1861,1867,1871,1873,1877,1879,1889, 1901,1907,1913,1931,1933,1949,1951,1973,1979,1987, 1993,1997,1999 }; int prime_factor(int n) { int i, b, d, w; sz = 0, b = (int)sqrt((double)n); for (i = 1; n > 1; i++) { if ((d = ptbl[i]) == 0) break; if (d > b) break; if (n % d) continue; factor[sz] = d, w = 0; do n /= d, w++; while (n % d == 0); power[sz++] = w; } if (n >= 2003) return 0; if (n > 1) factor[sz] = n, power[sz++] = 1; return 1; } int bit[TBL][MAX], bitn; void add(int k, int i, int v) { while (i <= bitn) bit[k][i] += v, i += i & -i; } int sum(int k, int i) { int s = 0; while (i > 0) s += bit[k][i], i -= i & -i; return s; } void calc_prime(int k, int n) { int i, v, w; for (i = 1; n > 1 && i <= SIZE; i++) { if (n % ptbl[i]) continue; v = ptbl[i], w = 0; do n /= v, w++; while (n % v == 0); add(i, k, w); } if (n > 1) add(id[n], k, 1); } int main() { int i, k, s, Q, ans; int P, L, R, _P, _L, _R, _a; for (i = 1; i < TBL; i++) id[ptbl[i]] = i; bitn = in(); for (i = 1; i <= bitn; i++) calc_prime(i, in()); Q = in(); _P = -1; while (Q--) { P = in(), L = in(), R = in(); if (P == _P && L == _L && R == _R) { ans = _a; goto done; } _P = P, _L = L, _R = R; ans = 0; if (P == 1) { ans = 1; goto done; } if (prime_factor(P)) { ans = 1; for (i = 0; i < sz; i++) { k = id[factor[i]]; s = sum(k, R); if (L > 1) s -= sum(k, L-1); if (s < power[i]) { ans = 0; break; } } } done: outs(ans? "Yes": "NO"); _a = ans; } return 0; }