結果

問題 No.1232 2^x = x
ユーザー lam6er
提出日時 2025-03-31 17:50:38
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 596 bytes
コンパイル時間 167 ms
コンパイル使用メモリ 82,164 KB
実行使用メモリ 66,092 KB
最終ジャッジ日時 2025-03-31 17:51:47
合計ジャッジ時間 5,564 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 1 TLE * 1 -- * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    import sys
    input = sys.stdin.read().split()
    N = int(input[0])
    primes = list(map(int, input[1:N+1]))
    
    for p in primes:
        if p == 2:
            print(2)
            continue
        
        found = False
        # Check x from 1 to 100_000
        max_check = 100000
        for x in range(1, max_check + 1):
            if pow(2, x, p) == x % p:
                print(x)
                found = True
                break
        
        if not found:
            x = (p - 1) ** 2
            print(x)
            
if __name__ == "__main__":
    main()
0