結果

問題 No.12 限定された素数
ユーザー antaanta
提出日時 2015-08-27 02:10:32
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 6,683 bytes
コンパイル時間 535 ms
コンパイル使用メモリ 73,864 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-15 23:05:47
合計ジャッジ時間 1,759 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 1 ms
4,376 KB
testcase_25 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
using namespace std;
typedef vector<int> vi; typedef pair<int,int> pii; typedef vector<pair<int,int> > vpii; typedef long long ll;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }

const int ume[1 << 10] = {
	-1, -1, 4, 28, 1, -1, 82, 94, 1, -1, 94, 100, 64, 104, 148, 124, //0
	-1, -1, 136, 86, -1, -1, 114, 72, 58, 82, 102, 124, 88, 108, 134, 192, //16
	2, -1, 76, 58, -1, -1, 64, 82, 86, 76, 112, 92, 112, 100, 100, 136, //32
	-1, -1, 106, 118, -1, -1, 82, 104, 90, 100, 116, 172, 94, 182, 158, 176, //48
	-1, -1, 50, 64, -1, -1, 82, 88, -1, -1, 78, 98, 76, 82, 138, 122, //64
	-1, -1, 92, 100, -1, -1, 96, 118, 78, 100, 118, 140, 96, 100, 124, 142, //80
	-1, -1, 68, 72, -1, -1, 82, 132, 86, 100, 118, 126, 90, 84, 126, 160, //96
	-1, -1, 90, 112, -1, -1, 112, 100, 148, 120, 174, 184, 188, 112, 146, 172, //112
	4, -1, 52, 112, 42, 72, 88, 108, 62, 124, 120, 130, 106, 120, 138, 190, //128
	38, 128, 148, 100, 76, 66, 134, 154, 108, 86, 136, 138, 120, 118, 172, 196, //144
	64, 52, 102, 98, 58, 122, 106, 148, 98, 112, 158, 152, 100, 124, 190, 196, //160
	82, 94, 130, 166, 94, 112, 146, 192, 118, 126, 168, 222, 148, 188, 194, 218, //176
	40, 68, 88, 88, 66, 88, 112, 152, 84, 106, 136, 140, 104, 126, 158, 228, //192
	72, 114, 106, 124, 86, 92, 148, 146, 106, 126, 150, 172, 136, 150, 202, 248, //208
	80, 54, 112, 122, 84, 90, 118, 120, 120, 126, 220, 186, 142, 120, 202, 248, //224
	106, 90, 108, 138, 104, 158, 184, 180, 178, 204, 190, 232, 208, 232, 280, 338, //240
	-1, -1, 32, 86, -1, -1, 94, 152, 96, 90, 106, 184, 120, 100, 130, 136, //256
	-1, -1, 76, 100, -1, -1, 100, 92, 78, 76, 106, 148, 142, 106, 136, 142, //272
	-1, -1, 82, 94, -1, -1, 124, 100, 68, 106, 104, 120, 88, 118, 118, 138, //288
	-1, -1, 96, 120, -1, -1, 120, 122, 112, 98, 130, 152, 118, 116, 160, 178, //304
	-1, -1, 62, 88, -1, -1, 112, 96, 104, 78, 118, 124, 78, 106, 108, 158, //320
	-1, -1, 106, 116, -1, -1, 104, 110, 88, 98, 146, 156, 104, 140, 152, 166, //336
	-1, -1, 86, 78, -1, -1, 82, 100, 88, 80, 130, 134, 106, 82, 120, 166, //352
	-1, -1, 100, 88, -1, -1, 106, 132, 102, 126, 128, 186, 136, 86, 218, 210, //368
	44, 40, 84, 106, 108, 82, 118, 158, 118, 136, 124, 208, 118, 128, 214, 202, //384
	82, 98, 110, 124, 100, 104, 134, 186, 136, 150, 166, 178, 148, 128, 264, 216, //400
	80, 68, 90, 102, 78, 96, 130, 134, 110, 100, 152, 182, 136, 138, 228, 252, //416
	82, 110, 132, 160, 126, 108, 138, 190, 128, 146, 198, 214, 138, 158, 270, 306, //432
	76, 66, 148, 112, 100, 112, 140, 178, 132, 116, 172, 190, 126, 136, 220, 228, //448
	82, 94, 134, 160, 96, 130, 166, 212, 150, 146, 218, 234, 148, 194, 270, 322, //464
	62, 118, 166, 124, 118, 122, 158, 160, 160, 124, 232, 272, 160, 176, 220, 282, //480
	90, 120, 166, 138, 116, 128, 178, 198, 184, 226, 260, 298, 172, 186, 298, 388, //496
	-1, -1, 58, 92, 58, 58, 82, 104, -1, -1, 108, 134, 134, 112, 196, 142, //512
	58, 84, 110, 126, 88, 94, 126, 142, 98, 120, 118, 154, 136, 134, 238, 198, //528
	46, 108, 82, 94, 80, 94, 112, 122, 146, 114, 124, 152, 128, 112, 178, 280, //544
	70, 92, 120, 150, 130, 94, 132, 146, 136, 158, 198, 190, 172, 148, 202, 278, //560
	-1, -1, 88, 100, 102, 96, 118, 148, -1, -1, 120, 168, 122, 124, 166, 202, //576
	92, 112, 122, 128, 104, 98, 116, 178, 124, 124, 154, 178, 136, 168, 208, 284, //592
	78, 72, 158, 112, 128, 82, 112, 160, 126, 138, 152, 192, 146, 128, 178, 238, //608
	100, 122, 126, 164, 98, 96, 144, 196, 132, 176, 240, 228, 148, 148, 266, 298, //624
	68, 58, 100, 154, 78, 94, 118, 136, 104, 134, 166, 196, 102, 126, 194, 288, //640
	86, 136, 118, 184, 136, 136, 148, 238, 124, 150, 156, 242, 230, 176, 342, 352, //656
	68, 78, 104, 112, 126, 108, 146, 180, 144, 192, 182, 190, 148, 166, 238, 358, //672
	118, 130, 166, 170, 152, 120, 180, 238, 170, 208, 252, 298, 248, 248, 396, 612, //688
	88, 76, 110, 158, 110, 118, 150, 208, 112, 166, 202, 202, 166, 160, 242, 364, //704
	102, 136, 156, 200, 124, 130, 198, 242, 160, 184, 232, 280, 178, 198, 354, 568, //720
	106, 94, 154, 192, 104, 138, 172, 218, 166, 196, 324, 260, 192, 212, 364, 508, //736
	118, 138, 196, 238, 136, 150, 228, 278, 208, 230, 478, 488, 220, 324, 516, 932, //752
	28, 78, 84, 82, 92, 100, 150, 190, 88, 152, 152, 212, 130, 124, 166, 194, //768
	80, 110, 136, 116, 84, 134, 148, 124, 108, 158, 178, 182, 132, 130, 236, 256, //784
	64, 52, 112, 94, 102, 100, 124, 150, 152, 156, 168, 174, 148, 136, 214, 292, //800
	94, 100, 122, 180, 96, 118, 148, 196, 156, 166, 186, 232, 172, 202, 268, 350, //816
	70, 66, 104, 128, 84, 96, 112, 192, 136, 130, 118, 178, 112, 142, 178, 208, //832
	88, 112, 128, 130, 98, 136, 118, 144, 126, 144, 208, 228, 148, 180, 214, 312, //848
	78, 82, 166, 148, 90, 94, 118, 172, 130, 132, 220, 292, 154, 158, 236, 298, //864
	86, 100, 160, 142, 98, 100, 142, 200, 164, 148, 244, 298, 160, 224, 360, 412, //880
	92, 72, 118, 152, 118, 102, 148, 206, 106, 156, 182, 262, 178, 178, 240, 366, //896
	98, 132, 142, 188, 130, 138, 172, 256, 146, 194, 258, 372, 190, 252, 362, 604, //912
	110, 80, 136, 166, 124, 136, 166, 222, 160, 178, 210, 296, 194, 260, 330, 464, //928
	114, 126, 174, 212, 142, 148, 196, 304, 202, 240, 318, 476, 226, 284, 514, 928, //944
	96, 88, 166, 182, 142, 138, 172, 268, 154, 180, 236, 332, 200, 238, 406, 598, //960
	116, 136, 192, 234, 128, 148, 222, 298, 172, 258, 416, 536, 244, 276, 432, 920, //976
	98, 118, 186, 200, 136, 148, 234, 328, 182, 218, 370, 470, 262, 288, 466, 928, //992
	126, 154, 256, 276, 132, 168, 308, 418, 248, 288, 492, 944, 294, 478, 940, 4999999, //1008
};

int main() {
	int N;
	while(~scanf("%d", &N)) {
		int des = 0;
		rep(i, N) {
			int A;
			scanf("%d", &A);
			des |= 1 << A;
		}
		int ans = ume[des];
		printf("%d\n", ans);
	}
	return 0;
}
0