QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#827670#8428. Partition into TeamsKazemaruWA 6ms14872kbC++14681b2024-12-23 08:01:482024-12-23 08:01:48

Judging History

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

  • [2024-12-23 08:01:48]
  • 评测
  • 测评结果:WA
  • 用时:6ms
  • 内存:14872kb
  • [2024-12-23 08:01:48]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define f(i,j,k) for(int i=j;i<=k;++i)
#define g(i,j,k) for(int i=j;i>=k;--i)
int n,m,s,l;
const int N=2e6;
int jc[N],ny[N],mo;
inline int ksm(int x,int p=mo-2,int y=1){for(;p;p/=2,x=x*x%mo)if(p&1)y=x*y%mo;return y;}
inline int C(int n,int m){return (n<m||m<0)?0:jc[n]*ny[m]%mo*ny[n-m]%mo;}
inline void ycl(int n){
	jc[0]=1;
	f(i,1,n)jc[i]=jc[i-1]*i%mo;
	ny[n]=ksm(jc[n]);
	g(i,n,1)ny[i-1]=ny[i]*i%mo;
}
int LC(int n,int m){return m?C(n/mo,m/mo)*C(n%mo,m%mo)%mo:1;}
signed main(){
	cin>>n>>mo;
	ycl(mo-1);
	f(i,0,n/2)m=(m+LC(n,i)*LC(n-i,i))%mo;
	cout<<(ksm(3,n)-m+mo)*ksm(2)%mo;
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 5668kb

input:

5 5

output:

1

result:

ok 1 number(s): "1"

Test #2:

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

input:

5 7

output:

5

result:

ok 1 number(s): "5"

Test #3:

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

input:

789 97

output:

53

result:

ok 1 number(s): "53"

Test #4:

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

input:

98 23

output:

10

result:

ok 1 number(s): "10"

Test #5:

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

input:

398 7

output:

4

result:

ok 1 number(s): "4"

Test #6:

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

input:

272 31

output:

18

result:

ok 1 number(s): "18"

Test #7:

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

input:

920 199

output:

39

result:

ok 1 number(s): "39"

Test #8:

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

input:

390 5167

output:

1236

result:

ok 1 number(s): "1236"

Test #9:

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

input:

445 24337

output:

4546

result:

ok 1 number(s): "4546"

Test #10:

score: 0
Accepted
time: 6ms
memory: 14872kb

input:

28 586501

output:

269032

result:

ok 1 number(s): "269032"

Test #11:

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

input:

304 5

output:

0

result:

ok 1 number(s): "0"

Test #12:

score: -100
Wrong Answer
time: 1ms
memory: 5736kb

input:

7158 41

output:

36

result:

wrong answer 1st numbers differ - expected: '16', found: '36'