23 条题解
-
-1神的崛起 LV 10 @ 2015-10-06 18:17:53
uses math;
var
i,j,k:longint;
x,y,z,n,m,ans:int64;
a:Array[0..100000]of int64;
begin
readln(n,m);
ans:=0;
x:=1;
for i:=1 to min(n,m)do
begin
x:=x*i;
x:=x mod m;
ans:=ans+x;
ans:=ans mod m;
end;
writeln(ans);
end. -
-12015-10-05 17:00:47@
#include <iostream>
#include <cstdio>using namespace std;
int main()
{
long long int n,f;
cin>>n>>f;
if(f==1||n==0)
{
cout<<0;
return 0;
}
if(n==1)
{
cout<<1;
return 0;
}
int i;
long long int ans=1;
long long int k=1;
for(i=2;i<f&&i<=n;++i)
{
k%=f;
k*=(i%f);
ans%=f;
ans+=(k%f);
}
cout<<ans%f;
return 0;
} -
-12015-10-05 07:45:42@
#include<cstdio>
unsigned long long n,m,k=1,b=1;
int main(){
scanf("%I64u%I64u",&n,&m);
if(m<n)n=m;
for(unsigned long long i=2;i<=n;i++){
b*=i;b%=m;
k+=b;k%=m;
}
printf("%I64u\n",k);
}
我绝对不会告诉你我交了12次才过