結果
| 問題 | No.109 N! mod M |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-10-31 23:16:15 |
| 言語 | PyPy2 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 294 bytes |
| 記録 | |
| コンパイル時間 | 130 ms |
| コンパイル使用メモリ | 77,048 KB |
| 実行使用メモリ | 87,816 KB |
| 最終ジャッジ日時 | 2024-09-13 06:39:48 |
| 合計ジャッジ時間 | 7,453 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 4 TLE * 1 -- * 4 |
ソースコード
#!/usr/bin/python for _ in range(input()): n,m=map(int,raw_input().split()) a=0 b=1 while b*-~b<=m: b+=1 if m%b<1: if n<b+m/b: a=1 while n: a=a*n%m n-=1 break else: if n<m: b=1 n+=1 while n<m: b=b*n%m n+=1 a=(m-1)*b**max(n-2,0)%m print(a)