結果
問題 | No.2954 Calculation of Exponentiation |
ユーザー |
|
提出日時 | 2024-11-08 21:47:26 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 49 ms / 2,000 ms |
コード長 | 1,484 bytes |
コンパイル時間 | 738 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 54,528 KB |
最終ジャッジ日時 | 2024-11-08 21:47:29 |
合計ジャッジ時間 | 2,708 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 28 |
ソースコード
import sys, randominput = lambda : sys.stdin.readline().rstrip()write = lambda x: sys.stdout.write(x+"\n"); writef = lambda x: print("{:.12f}".format(x))debug = lambda x: sys.stderr.write(x+"\n")YES="Yes"; NO="No"; pans = lambda v: print(YES if v else NO); INF=10**18LI = lambda v=0: list(map(lambda i: int(i)-v, input().split())); II=lambda : int(input()); SI=lambda : [ord(c)-ord("a") for c in input()]def debug(_l_):for s in _l_.split():print(f"{s}={eval(s)}", end=" ")print()def dlist(*l, fill=0):if len(l)==1:return [fill]*l[0]ll = l[1:]return [dlist(*ll, fill=fill) for _ in range(l[0])]def factor(n, m=None):# mを与えると、高々その素因数まで見て、残りは分解せずにそのまま出力するf = {}tmp = nM = int(-(-n**0.5//1))+1if m is not None:M = min(m+1, M)for i in range(2, M+1):if tmp<i:breakif tmp%i==0:cnt=0while tmp%i==0:cnt+=1tmp //= if[i] = cntif tmp!=1:f[tmp] = 1if not f:f[n] = 1return fa,b = [float(v) for v in input().split()]if b<0:b *= -1a = 1/aif a==1 or b==0:ans = 1elif a%1!=0:ans = 0else:f = factor(int(a))ng = 0for k,v in f.items():if k!=1:if abs(int(v*b+1e-7) - v*b)>0:ng = 1breakans = not ngpans(ans)