結果
問題 | No.308 素数は通れません |
ユーザー | asi1024 |
提出日時 | 2015-12-15 14:22:00 |
言語 | C++11 (gcc 11.4.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,092 bytes |
コンパイル時間 | 1,393 ms |
コンパイル使用メモリ | 160,880 KB |
実行使用メモリ | 23,552 KB |
最終ジャッジ日時 | 2024-09-15 13:03:18 |
合計ジャッジ時間 | 14,123 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge6 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 97 ms
19,456 KB |
testcase_01 | AC | 100 ms
19,328 KB |
testcase_02 | AC | 97 ms
19,456 KB |
testcase_03 | AC | 91 ms
19,328 KB |
testcase_04 | AC | 102 ms
19,328 KB |
testcase_05 | AC | 93 ms
19,456 KB |
testcase_06 | AC | 90 ms
19,328 KB |
testcase_07 | AC | 94 ms
19,328 KB |
testcase_08 | AC | 97 ms
19,328 KB |
testcase_09 | AC | 91 ms
19,456 KB |
testcase_10 | AC | 92 ms
19,200 KB |
testcase_11 | AC | 96 ms
19,328 KB |
testcase_12 | AC | 95 ms
19,456 KB |
testcase_13 | AC | 97 ms
19,328 KB |
testcase_14 | AC | 96 ms
19,328 KB |
testcase_15 | AC | 93 ms
19,456 KB |
testcase_16 | AC | 95 ms
19,456 KB |
testcase_17 | AC | 102 ms
19,328 KB |
testcase_18 | AC | 93 ms
19,456 KB |
testcase_19 | AC | 97 ms
19,456 KB |
testcase_20 | AC | 95 ms
19,328 KB |
testcase_21 | AC | 93 ms
19,456 KB |
testcase_22 | AC | 98 ms
19,456 KB |
testcase_23 | AC | 99 ms
19,328 KB |
testcase_24 | AC | 104 ms
19,456 KB |
testcase_25 | AC | 107 ms
19,456 KB |
testcase_26 | AC | 103 ms
19,456 KB |
testcase_27 | AC | 100 ms
19,456 KB |
testcase_28 | AC | 100 ms
19,328 KB |
testcase_29 | AC | 97 ms
19,328 KB |
testcase_30 | AC | 102 ms
19,328 KB |
testcase_31 | AC | 95 ms
19,328 KB |
testcase_32 | AC | 99 ms
19,456 KB |
testcase_33 | AC | 98 ms
19,456 KB |
testcase_34 | AC | 96 ms
19,456 KB |
testcase_35 | AC | 94 ms
19,456 KB |
testcase_36 | AC | 94 ms
19,456 KB |
testcase_37 | AC | 91 ms
19,456 KB |
testcase_38 | AC | 97 ms
19,328 KB |
testcase_39 | AC | 96 ms
19,456 KB |
testcase_40 | AC | 91 ms
19,328 KB |
testcase_41 | AC | 91 ms
19,328 KB |
testcase_42 | AC | 92 ms
19,328 KB |
testcase_43 | AC | 90 ms
19,328 KB |
testcase_44 | AC | 96 ms
19,200 KB |
testcase_45 | AC | 94 ms
19,328 KB |
testcase_46 | AC | 94 ms
19,328 KB |
testcase_47 | AC | 93 ms
19,328 KB |
testcase_48 | AC | 95 ms
19,328 KB |
testcase_49 | AC | 92 ms
19,328 KB |
testcase_50 | AC | 92 ms
19,456 KB |
testcase_51 | AC | 93 ms
19,456 KB |
testcase_52 | AC | 92 ms
19,584 KB |
testcase_53 | AC | 94 ms
19,584 KB |
testcase_54 | AC | 90 ms
19,584 KB |
testcase_55 | AC | 91 ms
19,456 KB |
testcase_56 | AC | 90 ms
21,120 KB |
testcase_57 | AC | 96 ms
21,120 KB |
testcase_58 | AC | 90 ms
19,328 KB |
testcase_59 | AC | 91 ms
19,328 KB |
testcase_60 | AC | 90 ms
19,200 KB |
testcase_61 | AC | 96 ms
19,328 KB |
testcase_62 | AC | 96 ms
19,456 KB |
testcase_63 | AC | 97 ms
19,456 KB |
testcase_64 | AC | 94 ms
19,456 KB |
testcase_65 | AC | 95 ms
19,456 KB |
testcase_66 | AC | 93 ms
19,456 KB |
testcase_67 | AC | 95 ms
19,456 KB |
testcase_68 | AC | 90 ms
19,328 KB |
testcase_69 | AC | 90 ms
19,328 KB |
testcase_70 | AC | 98 ms
19,328 KB |
testcase_71 | AC | 93 ms
19,456 KB |
testcase_72 | AC | 91 ms
19,328 KB |
testcase_73 | AC | 95 ms
19,328 KB |
testcase_74 | AC | 93 ms
19,328 KB |
testcase_75 | AC | 93 ms
19,328 KB |
testcase_76 | AC | 98 ms
23,552 KB |
testcase_77 | AC | 94 ms
21,760 KB |
testcase_78 | AC | 91 ms
19,328 KB |
testcase_79 | AC | 92 ms
19,328 KB |
testcase_80 | WA | - |
testcase_81 | WA | - |
testcase_82 | AC | 92 ms
19,328 KB |
testcase_83 | AC | 95 ms
19,456 KB |
testcase_84 | WA | - |
testcase_85 | AC | 93 ms
19,328 KB |
testcase_86 | WA | - |
testcase_87 | WA | - |
testcase_88 | AC | 95 ms
19,456 KB |
testcase_89 | AC | 94 ms
19,328 KB |
testcase_90 | WA | - |
testcase_91 | AC | 93 ms
19,328 KB |
testcase_92 | AC | 99 ms
19,328 KB |
testcase_93 | AC | 94 ms
19,456 KB |
testcase_94 | AC | 92 ms
19,456 KB |
testcase_95 | AC | 92 ms
19,456 KB |
testcase_96 | AC | 93 ms
19,328 KB |
testcase_97 | AC | 99 ms
19,456 KB |
testcase_98 | AC | 92 ms
19,200 KB |
testcase_99 | AC | 92 ms
19,328 KB |
testcase_100 | AC | 94 ms
19,328 KB |
testcase_101 | WA | - |
testcase_102 | AC | 90 ms
19,456 KB |
testcase_103 | AC | 88 ms
19,328 KB |
testcase_104 | AC | 90 ms
19,328 KB |
testcase_105 | AC | 93 ms
19,456 KB |
testcase_106 | AC | 95 ms
19,328 KB |
ソースコード
#include <bits/stdc++.h> #define REP(i,n) for(int i=0;i<(int)(n);i++) #define ALL(x) (x).begin(),(x).end() using namespace std; typedef long long ll; const int SIZE = 16384000; const int dx[4] = {1, 0, -1, 0}; const int dy[4] = {0, 1, 0, -1}; bool p[SIZE]; bool dfs(int y, int x, int t, int w, vector<bool> &visited) { if (y < 0 || x < 0 || x >= w) return false; int n = y * w + x + 1; if (n > t) return false; if (n == t) return true; if (p[n]) return false; if (visited[n]) return false; visited[n] = true; REP(dir,4) if (dfs(y + dy[dir], x + dx[dir], t, w, visited)) return true; return false; } int solve(string str) { if (str.size() >= 7) return 8; int N = stoi(str); for (int i = 1; i < N; ++i) { vector<bool> visited(N+1, false); if (dfs(0, 0, N, i, visited)) return i; } return -1; } int main() { for (int i = 2; i < SIZE; ++i) p[i] = true; for (int i = 2; i*i <= SIZE; ++i) if (p[i]) for (int j = i*i; j <= SIZE; j += i) p[j] = false; string str; cin >> str; cout << solve(str) << endl; return 0; }