QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#437487 | #8792. Candies | ucup-team1004 | AC ✓ | 1990ms | 4184kb | C++14 | 1.4kb | 2024-06-09 11:45:31 | 2024-06-09 11:45:32 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#ifdef DEBUG
#include"debug.h"
#else
#define debug(...) void()
#endif
#define all(x) (x).begin(),(x).end()
template<class T>
auto ary(T *a,int l,int r){
return vector<T>{a+l,a+1+r};
}
using ll=long long;
using ull=unsigned ll;
const int N=3e4+10,mod=998244353;
ll qpow(ll x,ll y=mod-2,ll ans=1){
for(;y;(x*=x)%=mod,y>>=1)if(y&1)(ans*=x)%=mod;
return ans;
}
int fac[N],ifac[N],pw[N],inv[N];
int C(int n,int m){
if(0>m||m>n)return 0;
return 1ll*fac[n]*ifac[m]%mod*ifac[n-m]%mod;
}
void init(int n=N-1){
for(int i=fac[0]=1;i<=n;i++)fac[i]=1ll*fac[i-1]*i%mod;
ifac[n]=qpow(fac[n]);
for(int i=n;i>=1;i--)ifac[i-1]=1ll*ifac[i]*i%mod;
for(int i=1;i<=n;i++)inv[i]=1ll*ifac[i]*fac[i-1]%mod;
for(int i=pw[0]=1;i<=n;i++)pw[i]=pw[i-1]*4ll%mod;
}
int a,b,c;
int go(int a,int b,int c){
if(min({a,b,c})<0)return 0;
return 1ll*fac[a+b+c]*ifac[a]%mod*ifac[b]%mod*ifac[c]%mod;
}
int calc(int n,int k){
return 1ll*pw[n]*(k+k+1)%mod*inv[n+k+1]%mod*inv[n+n+k+k+1]%mod*C(k+k,k)%mod*C(n+n+n+k+k,n)%mod;
}
int main(){
cin>>a>>b>>c,init();
int ans=0;
for(int i=0;i<b;i++){
for(int j=0;j<=i&&j<=c;j++){
ans=(ans+1ll*calc(j,i-j)*go(a-i,b-i-1,c-j))%mod;
}
}
for(int i=0;i<c;i++){
for(int j=0;j<=i&&j<=b;j++){
ans=(ans+1ll*calc(j,i-j)*go(a-i,b-j,c-i-1))%mod;
}
}
ans=(go(a,b,c)+mod-ans)%mod;
cout<<ans<<endl;
return 0;
}
#ifdef DEBUG
#include"debug.hpp"
#endif
这程序好像有点Bug,我给组数据试试?
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 4036kb
input:
4 3 2
output:
368
result:
ok answer is '368'
Test #2:
score: 0
Accepted
time: 1990ms
memory: 4120kb
input:
10000 10000 10000
output:
905642282
result:
ok answer is '905642282'
Test #3:
score: 0
Accepted
time: 1ms
memory: 4168kb
input:
99 99 99
output:
604759627
result:
ok answer is '604759627'
Test #4:
score: 0
Accepted
time: 1289ms
memory: 4100kb
input:
10000 9876 6543
output:
172894229
result:
ok answer is '172894229'
Test #5:
score: 0
Accepted
time: 1ms
memory: 4120kb
input:
7 1 6
output:
5577
result:
ok answer is '5577'
Test #6:
score: 0
Accepted
time: 1ms
memory: 3984kb
input:
28 23 17
output:
816429586
result:
ok answer is '816429586'
Test #7:
score: 0
Accepted
time: 1ms
memory: 3984kb
input:
87 54 22
output:
401507657
result:
ok answer is '401507657'
Test #8:
score: 0
Accepted
time: 1ms
memory: 4108kb
input:
50 40 16
output:
770938562
result:
ok answer is '770938562'
Test #9:
score: 0
Accepted
time: 1ms
memory: 4124kb
input:
72 19 53
output:
607733148
result:
ok answer is '607733148'
Test #10:
score: 0
Accepted
time: 1ms
memory: 4184kb
input:
8 4 4
output:
325590
result:
ok answer is '325590'
Test #11:
score: 0
Accepted
time: 1ms
memory: 4168kb
input:
65 45 14
output:
452076388
result:
ok answer is '452076388'
Test #12:
score: 0
Accepted
time: 1ms
memory: 4028kb
input:
82 8 67
output:
708832480
result:
ok answer is '708832480'
Test #13:
score: 0
Accepted
time: 0ms
memory: 3988kb
input:
65 10 35
output:
769016918
result:
ok answer is '769016918'
Test #14:
score: 0
Accepted
time: 1ms
memory: 4100kb
input:
4 3 4
output:
1408
result:
ok answer is '1408'
Test #15:
score: 0
Accepted
time: 37ms
memory: 4112kb
input:
9139 6356 279
output:
833879698
result:
ok answer is '833879698'
Test #16:
score: 0
Accepted
time: 94ms
memory: 4172kb
input:
3888 2407 1937
output:
380556889
result:
ok answer is '380556889'
Test #17:
score: 0
Accepted
time: 498ms
memory: 4112kb
input:
9161 3171 7913
output:
643956900
result:
ok answer is '643956900'
Test #18:
score: 0
Accepted
time: 26ms
memory: 4108kb
input:
1392 1354 938
output:
491399135
result:
ok answer is '491399135'
Test #19:
score: 0
Accepted
time: 10ms
memory: 4028kb
input:
5930 427 1403
output:
786969030
result:
ok answer is '786969030'
Test #20:
score: 0
Accepted
time: 1ms
memory: 4164kb
input:
507 99 150
output:
960656496
result:
ok answer is '960656496'
Test #21:
score: 0
Accepted
time: 127ms
memory: 4168kb
input:
3119 2372 2681
output:
751161512
result:
ok answer is '751161512'
Test #22:
score: 0
Accepted
time: 199ms
memory: 4164kb
input:
6636 3688 2743
output:
839083240
result:
ok answer is '839083240'
Test #23:
score: 0
Accepted
time: 28ms
memory: 3980kb
input:
4890 475 2865
output:
788640273
result:
ok answer is '788640273'
Test #24:
score: 0
Accepted
time: 81ms
memory: 4108kb
input:
6708 663 6384
output:
426276232
result:
ok answer is '426276232'
Test #25:
score: 0
Accepted
time: 1ms
memory: 4116kb
input:
1 1 1
output:
2
result:
ok answer is '2'
Extra Test:
score: 0
Extra Test Passed