結果
問題 | No.1255 ハイレーツ・オブ・ボリビアン |
ユーザー | yuusanlondon |
提出日時 | 2020-10-09 23:18:14 |
言語 | PyPy3 (7.3.15) |
結果 |
RE
|
実行時間 | - |
コード長 | 2,074 bytes |
コンパイル時間 | 160 ms |
コンパイル使用メモリ | 82,048 KB |
実行使用メモリ | 851,840 KB |
最終ジャッジ日時 | 2024-07-20 14:13:37 |
合計ジャッジ時間 | 2,788 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 41 ms
52,224 KB |
testcase_01 | AC | 41 ms
52,736 KB |
testcase_02 | AC | 54 ms
59,520 KB |
testcase_03 | AC | 48 ms
59,776 KB |
testcase_04 | AC | 50 ms
59,264 KB |
testcase_05 | AC | 109 ms
122,880 KB |
testcase_06 | AC | 110 ms
125,056 KB |
testcase_07 | AC | 111 ms
126,592 KB |
testcase_08 | RE | - |
testcase_09 | RE | - |
testcase_10 | MLE | - |
testcase_11 | -- | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
ソースコード
# Python3 program to calculate # discrete logarithm import math; def discreteLogarithm(a, b, m): n = int(math.sqrt (m) + 1); # Calculate a ^ n an = 1; for i in range(n): an = (an * a) % m; value = [0] * m; # Store all values of a^(n*i) of LHS cur = an; for i in range(1, n + 1): if (value[ cur ] == 0): value[ cur ] = i; cur = (cur * an) % m; cur = b; for i in range(n + 1): # Calculate (a ^ j) * b and check # for collision if (value[cur] > 0): ans = value[cur] * n - i; if (ans < m): return ans; cur = (cur * a) % m; return -1; # A simple Python3 program # to calculate Euler's # Totient Function # Function to return # gcd of a and b def gcd(a, b): if (a == 0): return b return gcd(b % a, a) # Python3 program to calculate # Euler's Totient Function def phi(n): # Initialize result as n result = n; # Consider all prime factors # of n and subtract their # multiples from result p = 2; while(p * p <= n): # Check if p is a # prime factor. if (n % p == 0): # If yes, then # update n and result while (n % p == 0): n = int(n / p); result -= int(result / p); p += 1; # If n has a prime factor # greater than sqrt(n) # (There can be at-most # one such prime factor) if (n > 1): result -= int(result / n); return result; # This code is contributed # by mits t=int(input()) for _ in range(t): n=int(input()) a=discreteLogarithm(2,1,2*n-1) totient=phi(2*n-1) while True: flag=0 count=2 while count*count<=totient: if totient%count==0 and pow(2,totient//count,2*n-1)==1: totient=totient//count break count+=1 if count*count>totient: flag=1 if flag==1: break print(totient)