結果
問題 |
No.774 tatyamと素数大富豪
|
ユーザー |
![]() |
提出日時 | 2018-12-22 00:07:09 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 624 bytes |
コンパイル時間 | 513 ms |
コンパイル使用メモリ | 54,784 KB |
実行使用メモリ | 16,576 KB |
最終ジャッジ日時 | 2024-09-25 09:47:22 |
合計ジャッジ時間 | 6,893 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | -- * 5 |
other | TLE * 1 -- * 13 |
ソースコード
#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; }