結果
問題 | No.774 tatyamと素数大富豪 |
ユーザー |
|
提出日時 | 2018-06-23 16:56:08 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,011 bytes |
コンパイル時間 | 516 ms |
コンパイル使用メモリ | 10,912 KB |
実行使用メモリ | 67,840 KB |
最終ジャッジ日時 | 2023-09-13 08:32:16 |
合計ジャッジ時間 | 14,482 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1,043 ms
67,128 KB |
testcase_01 | AC | 19 ms
8,776 KB |
testcase_02 | AC | 1,107 ms
65,728 KB |
testcase_03 | AC | 32 ms
9,636 KB |
testcase_04 | AC | 19 ms
8,808 KB |
testcase_05 | AC | 21 ms
8,932 KB |
testcase_06 | AC | 18 ms
8,804 KB |
testcase_07 | AC | 18 ms
8,772 KB |
testcase_08 | AC | 18 ms
8,796 KB |
testcase_09 | AC | 1,157 ms
67,540 KB |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | AC | 1,040 ms
67,660 KB |
testcase_13 | AC | 1,046 ms
67,012 KB |
testcase_14 | AC | 145 ms
15,236 KB |
testcase_15 | WA | - |
testcase_16 | AC | 1,165 ms
67,404 KB |
testcase_17 | AC | 1,043 ms
66,956 KB |
testcase_18 | WA | - |
ソースコード
#coding:utf8 import random import itertools def is_prime(q,k=30): q = abs(q) #計算するまでもなく判定できるものははじく if q == 2: return True if q < 2 or q&1 == 0: return False #n-1=2^s*dとし(但しaは整数、dは奇数)、dを求める d = (q-1)>>1 while d&1 == 0: d >>= 1 #判定をk回繰り返す for i in range(k): a = random.randint(1,q-1) t = d y = pow(a,t,q) #[0,s-1]の範囲すべてをチェック while t != q-1 and y != 1 and y != q-1: y = pow(y,2,q) t <<= 1 if y != q-1 and t&1 == 0: return False return True n=int(input()) a=list(map(int,input().split())) v=list(itertools.permutations(a)) m=-1 s=[] for i in v: p=int(float(''.join(map(str,i)))) s.append(p) s.sort(reverse=True) x=1 p=0 for i in s: if p!=i: if is_prime(i): print(i) x=0 break p=i if x==1: print(-1)