python3-n的阶乘

51nod-n的阶乘

Input
两个数N,P,中间用空格隔开。(N < 10000, P < 10^9)
Output
输出N! mod P的结果。
Input示例
10 11
Output示例
10

import math
a,b = map(int,input().split())
s = math.factorial(a)%b
print(s,"\n")
在一行输入多个变量,
a,b = input().split()

此时的a,b都是字符型

如果需要数值型

a,b = map(int,input().split())

在math库中有阶乘函数,math.factorial()

猜你喜欢

转载自blog.csdn.net/qq_41003528/article/details/80203237