結果

問題 No.308 素数は通れません
ユーザー sugim48sugim48
提出日時 2015-12-01 00:46:46
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,692 bytes
コンパイル時間 754 ms
コンパイル使用メモリ 84,728 KB
実行使用メモリ 4,720 KB
最終ジャッジ日時 2023-10-12 06:12:30
合計ジャッジ時間 34,621 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 283 ms
4,416 KB
testcase_01 AC 283 ms
4,524 KB
testcase_02 AC 281 ms
4,488 KB
testcase_03 AC 282 ms
4,464 KB
testcase_04 AC 282 ms
4,580 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 284 ms
4,416 KB
testcase_08 AC 282 ms
4,512 KB
testcase_09 AC 282 ms
4,464 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 284 ms
4,412 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 283 ms
4,480 KB
testcase_16 AC 282 ms
4,472 KB
testcase_17 AC 282 ms
4,472 KB
testcase_18 AC 283 ms
4,460 KB
testcase_19 AC 282 ms
4,528 KB
testcase_20 AC 283 ms
4,412 KB
testcase_21 AC 283 ms
4,432 KB
testcase_22 AC 282 ms
4,408 KB
testcase_23 AC 283 ms
4,512 KB
testcase_24 AC 283 ms
4,464 KB
testcase_25 AC 282 ms
4,464 KB
testcase_26 AC 283 ms
4,464 KB
testcase_27 AC 284 ms
4,512 KB
testcase_28 AC 283 ms
4,524 KB
testcase_29 AC 283 ms
4,468 KB
testcase_30 AC 283 ms
4,484 KB
testcase_31 AC 284 ms
4,588 KB
testcase_32 WA -
testcase_33 AC 283 ms
4,528 KB
testcase_34 AC 287 ms
4,412 KB
testcase_35 AC 283 ms
4,408 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
testcase_51 WA -
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 AC 283 ms
4,416 KB
testcase_77 WA -
testcase_78 WA -
testcase_79 WA -
testcase_80 AC 283 ms
4,580 KB
testcase_81 AC 282 ms
4,400 KB
testcase_82 WA -
testcase_83 WA -
testcase_84 AC 282 ms
4,516 KB
testcase_85 WA -
testcase_86 AC 284 ms
4,524 KB
testcase_87 AC 282 ms
4,608 KB
testcase_88 WA -
testcase_89 WA -
testcase_90 AC 284 ms
4,412 KB
testcase_91 WA -
testcase_92 WA -
testcase_93 WA -
testcase_94 WA -
testcase_95 WA -
testcase_96 WA -
testcase_97 WA -
testcase_98 WA -
testcase_99 WA -
testcase_100 WA -
testcase_101 AC 283 ms
4,464 KB
testcase_102 WA -
testcase_103 WA -
testcase_104 WA -
testcase_105 WA -
testcase_106 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int dy[4] = {0, -1, 0, 1};
int dx[4] = {-1, 0, 1, 0};

void dfs(int y, int x, vector<vector<int> >& a, vector<int>& mi) {
	int H = a.size(), W = a[0].size();
	for (int k = 0; k < 4; k++) {
		int _y = y + dy[k], _x = x + dx[k];
		if (_y >= 0 && _y < H && _x >= 0 && _x < W && a[_y][_x]) {
			mi[a[_y][_x]] = min(mi[a[_y][_x]], W);
			a[_y][_x] = 0;
			dfs(_y, _x, a, mi);
		}
	}
}

int main() {
	vector<bool> p(10000, true);
	p[1] = false;
	for (int i = 2; i < 10000; i++)
		if (p[i])
			for (int j = i * 2; j < 10000; j += i)
				p[j] = false;
	vector<int> mi(10000, INT_MAX);
	for (int W = 1; W <= 1000; W++) {
		vector<vector<int> > a(10000 / W + 1, vector<int>(W));
		for (int i = 1; i < 10000; i++)
			if (!p[i])
				a[(i - 1) / W][(i - 1) % W] = i;
		dfs(0, 0, a, mi);
	}
	string s; cin >> s;
	int n = s.length();
	if (n <= 3) {
		stringstream ss(s);
		int x; ss >> x;
		cout << mi[x] << endl;
		return 0;
	}
	int x = 0;
	for (int i = 0; i < s.length(); i++)
		x = (x * 10 + s[i] - '0') % 14;
	if (x != 1) cout << 14 << endl;
}
0