結果

問題 No.774 tatyamと素数大富豪
ユーザー kriiikriii
提出日時 2018-12-22 00:07:09
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 624 bytes
コンパイル時間 1,818 ms
コンパイル使用メモリ 54,648 KB
実行使用メモリ 11,796 KB
最終ジャッジ日時 2023-10-26 01:40:19
合計ジャッジ時間 7,736 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <algorithm>
#include <set>
using namespace std;

bool isp(long long x)
{
	if (x == 1) return false;
	for (long long i=2;i*i<=x;i++) if (x % i == 0) return false;
	return true;
}

int main()
{
	int N; scanf ("%d",&N);
	int A[10]; for (int i=0;i<N;i++) scanf ("%d",&A[i]);

	long long ans = -1;
	set<long long> chk;
	do{
		long long a = 0;
		for (int i=0;i<N;i++){
			if (A[i] < 10) a = a * 10 + A[i];
			else a = a * 100 + A[i];
		}
		if (chk.count(a)) continue;
		else{
			chk.insert(a);
			if (isp(a)) ans = max(ans,a);
		}
	}while(next_permutation(A,A+N));

	printf ("%lld\n",ans);
	return 0;
}
0