QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#262784#7774. 基础寄术练习题Crysfly25 1ms3512kbC++172.8kb2023-11-24 00:35:062023-11-24 00:35:07

Judging History

你现在查看的是最新测评结果

  • [2023-11-24 00:35:07]
  • 评测
  • 测评结果:25
  • 用时:1ms
  • 内存:3512kb
  • [2023-11-24 00:35:06]
  • 提交

answer

// what is matter? never mind. 
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,sse4,popcnt,abm,mmx,avx,avx2") 
#include<bits/stdc++.h>
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define Rep(i,a,b) for(int i=(a);i>=(b);--i)
#define ll long long
//#define ull unsigned long long
using namespace std;
inline int read()
{
	char c=getchar();int x=0;bool f=0;
	for(;!isdigit(c);c=getchar())f^=!(c^45);
	for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+(c^48);
	if(f)x=-x;return x;
}
 
int mod;
typedef unsigned long long ull;
namespace FM{
	typedef __uint128_t L;
	struct FastMod{
		ull b,m;
		FastMod(ull b):b(b),m(ull((L(1)<<64)/b)){}
		ull reduce(ull a){ull q=(ull)((L(m)*a)>>64),r=a-q*b;return r>=b?r-b:r;}
	};
	FastMod F(2);
}

struct modint{
	int x;
	modint(int o=0){x=o;}
	modint &operator = (int o){return x=o,*this;}
	modint &operator +=(modint o){return x=x+o.x>=mod?x+o.x-mod:x+o.x,*this;}
	modint &operator -=(modint o){return x=x-o.x<0?x-o.x+mod:x-o.x,*this;}
	modint &operator *=(modint o){return x=FM::F.reduce(1ull*x*o.x),*this;}
	modint &operator ^=(int b){
		modint a=*this,c=1;
		for(;b;b>>=1,a*=a)if(b&1)c*=a;
		return x=c.x,*this;
	}
	modint &operator /=(modint o){return *this *=o^=mod-2;}
	friend modint operator +(modint a,modint b){return a+=b;}
	friend modint operator -(modint a,modint b){return a-=b;}
	friend modint operator *(modint a,modint b){return a*=b;}
	friend modint operator /(modint a,modint b){return a/=b;}
	friend modint operator ^(modint a,int b){return a^=b;}
	friend bool operator ==(modint a,int b){return a.x==b;}
	friend bool operator !=(modint a,int b){return a.x!=b;}
	bool operator ! () {return !x;}
	modint operator - () {return x?mod-x:0;}
	bool operator <(const modint&b)const{return x<b.x;}
};
inline modint qpow(modint x,int y){return x^y;}
void initmod(){mod=read(),FM::F=FM::FastMod(mod);}

vector<modint> fac,ifac,iv;
inline void initC(int n)
{
	if(iv.empty())fac=ifac=iv=vector<modint>(2,1);
	int m=iv.size(); ++n;
	if(m>=n)return;
	iv.resize(n),fac.resize(n),ifac.resize(n);
	For(i,m,n-1){
		iv[i]=iv[mod%i]*(mod-mod/i);
		fac[i]=fac[i-1]*i,ifac[i]=ifac[i-1]*iv[i];
	}
}
inline modint C(int n,int m){
	if(m<0||n<m)return 0;
	return initC(n),fac[n]*ifac[m]*ifac[n-m];
}
inline modint sign(int n){return (n&1)?(mod-1):(1);}

#define fi first
#define se second
#define pb push_back
#define mkp make_pair
typedef pair<int,int>pii;
typedef vector<int>vi;

#define maxn 1000005
#define inf 0x3f3f3f3f

int n,m,k;

modint dp[105][105];
void solve1(){
	dp[0][0]=1;
	For(i,1,m){
		For(j,0,i)
			dp[i][j]=dp[i-1][j]+dp[i-1][j-1]*iv[i];
	}
	cout<<dp[m][n].x<<"\n";
	exit(0);
}

signed main()
{
	n=read(),m=read(),k=read(),initmod();initC(105);
	if(k==1)solve1();
	return 0;
}
/*
3 1
1 0 0 0
*/

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 10
Accepted
time: 0ms
memory: 3392kb

input:

9 16 1 327134593

output:

162102742

result:

ok single line: '162102742'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3412kb

input:

11 18 1 834359503

output:

256188485

result:

ok single line: '256188485'

Test #3:

score: 0
Accepted
time: 0ms
memory: 3404kb

input:

18 18 1 614802701

output:

552168146

result:

ok single line: '552168146'

Test #4:

score: -10
Wrong Answer
time: 0ms
memory: 3416kb

input:

7 16 2 861918403

output:


result:

wrong answer 1st lines differ - expected: '306693876', found: ''

Subtask #2:

score: 25
Accepted

Test #6:

score: 25
Accepted
time: 0ms
memory: 3504kb

input:

60 98 1 715015339

output:

690737273

result:

ok single line: '690737273'

Test #7:

score: 0
Accepted
time: 1ms
memory: 3400kb

input:

96 97 1 507892589

output:

481151247

result:

ok single line: '481151247'

Test #8:

score: 0
Accepted
time: 0ms
memory: 3424kb

input:

90 95 1 621080027

output:

255353202

result:

ok single line: '255353202'

Test #9:

score: 0
Accepted
time: 0ms
memory: 3360kb

input:

85 94 1 297115421

output:

122254364

result:

ok single line: '122254364'

Test #10:

score: 0
Accepted
time: 0ms
memory: 3512kb

input:

81 91 1 460412027

output:

148037986

result:

ok single line: '148037986'

Subtask #3:

score: 0
Wrong Answer

Test #11:

score: 0
Wrong Answer
time: 1ms
memory: 3412kb

input:

29 29 2 545875273

output:


result:

wrong answer 1st lines differ - expected: '171843225', found: ''

Subtask #4:

score: 0
Wrong Answer

Test #16:

score: 0
Wrong Answer
time: 0ms
memory: 3408kb

input:

27 30 2 360712453

output:


result:

wrong answer 1st lines differ - expected: '80987914', found: ''

Subtask #5:

score: 0
Wrong Answer

Test #21:

score: 0
Wrong Answer
time: 0ms
memory: 3452kb

input:

29 38 2 909155077

output:


result:

wrong answer 1st lines differ - expected: '745973305', found: ''

Subtask #6:

score: 0
Wrong Answer

Test #26:

score: 0
Wrong Answer
time: 0ms
memory: 3388kb

input:

57 66 2 767174999

output:


result:

wrong answer 1st lines differ - expected: '315351738', found: ''

Subtask #7:

score: 0
Wrong Answer

Test #31:

score: 0
Wrong Answer
time: 0ms
memory: 3424kb

input:

96 96 2 453296971

output:


result:

wrong answer 1st lines differ - expected: '222864385', found: ''