結果

問題 No.109 N! mod M
ユーザー cielciel
提出日時 2015-10-31 23:10:17
言語 PyPy2
(7.3.15)
結果
WA  
実行時間 -
コード長 322 bytes
コンパイル時間 132 ms
コンパイル使用メモリ 77,112 KB
実行使用メモリ 78,396 KB
最終ジャッジ日時 2023-10-11 07:34:49
合計ジャッジ時間 2,010 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 RE -
testcase_08 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/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:
			print([0,m,b])
			if n<b+m/b:
				print([n,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=pow(m-1,n-2,m)
	print(a)
0