結果
| 問題 | No.2972 確率的素数判定 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-11-29 21:38:15 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 353 ms / 2,000 ms |
| コード長 | 1,212 bytes |
| コンパイル時間 | 147 ms |
| コンパイル使用メモリ | 82,432 KB |
| 実行使用メモリ | 96,768 KB |
| 最終ジャッジ日時 | 2024-11-29 21:38:23 |
| 合計ジャッジ時間 | 7,383 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 20 |
ソースコード
import collections,sys,math,functools,operator,itertools,bisect,heapq,decimal,string,time,random
#sys.setrecursionlimit(10**9)
#sys.set_int_max_str_digits(0)
def MillerRabin_64bit(x):
if x <= 1:
return False
if x == 2:
return True
if x % 2 == 0:
return False
if x < 1 << 30:
test = [2, 7, 61]
else:
test = [2,325,9375,28178,450775,9780504,1795265022]
s = 0
d = x - 1
while d & 1 == 0:
s += 1
d >>= 1
for i in test:
if x <= i:
return True
y = pow(i,d,x)
if y == 1 or y == x - 1:
continue
c = 0
for j in range(s-1):
y = y * y % x
if y == x - 1:
c = 1
break
if not c:
return False
return True
input = sys.stdin.readline
#n = int(input())
#alist = list(map(int,input().split()))
#alist = []
#s = input()
t = int(input())
a = [1 if MillerRabin_64bit(i) else 0 for i in range(100000+10)]
a = list(itertools.accumulate(a))
def solve():
n,p,q = map(int,input().split())
x = a[n]
print((p/100 * x/n) / (p/100 * x/n + (100-q)/100 * (n-x)/n))
for i in range(t):
solve()