QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#700872 | #53. Boom! | TheZone | 100 ✓ | 16ms | 11716kb | C++23 | 1.6kb | 2024-11-02 13:28:58 | 2024-11-02 13:29:00 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int maxn=1005;
const int mod=10301;
int read(){
int ret=0,f=1;char ch=getchar();
while(!isdigit(ch)){if(ch=='-')f=-f;ch=getchar();}
while( isdigit(ch)){ret=(ret<<3)+(ret<<1)+(ch&15);ch=getchar();}
return ret*f;
}
int n,A,B,ans;
int g1[maxn][maxn],g2[maxn][maxn],f1[maxn],f2[maxn];
int main(){
n=read();A=read();B=read();
for(int i=A;i<=n;++i) g1[0][i]=1;
for(int i=A;i<=n;++i){
for(int j=1;j<=i;++j){
g1[i][j]=(g1[i][j]+g1[i-j][j])%mod;
}
for(int j=1;j<=n;++j){
if(i+j<=n) f1[i+j]=(f1[i+j]+g1[i][j])%mod;
g1[i][j]=(g1[i][j]+g1[i][j-1])%mod;
}
}
f1[A]=1;
for(int i=B;i<=n;++i) g2[0][i]=1;
for(int i=B;i<=n;++i){
for(int j=1;j<=i;++j){
g2[i][j]=(g2[i][j]+g2[i-j][j])%mod;
}
for(int j=1;j<=n;++j){
if(i+j<=n) f2[i+j]=(f2[i+j]+g2[i][j])%mod;
g2[i][j]=(g2[i][j]+g2[i][j-1])%mod;
}
}
f2[B]=1;
for(int i=1;i<=n;++i){
for(int j=1;j<=n;++j){
if(i+j>n) break;
ans=(ans+1ll*f1[i]*f2[j])%mod;
}
}
printf("%d\n",ans);
return 0;
}
/*#include <bits/stdc++.h>
using namespace std;
const int maxn=1005;
const int mod=10301;
int read(){
int ret=0,f=1;char ch=getchar();
while(!isdigit(ch)){if(ch=='-')f=-f;ch=getchar();}
while( isdigit(ch)){ret=(ret<<3)+(ret<<1)+(ch&15);ch=getchar();}
return ret*f;
}
int n,A,B,ans;
int g1[maxn][maxn],g2[maxn][maxn],f1[maxn],f2[maxn];
int main(){
n=read();A=read();B=read();
for(int i=A;i<=n;++i) g1[0][i]=1;
for(int i=A;i<=n;++i){
for(int j=1;j<=i;++j){
}
printf("%d\n",ans);
return 0;
} */
Details
Tip: Click on the bar to expand more detailed information
Pretests
Final Tests
Test #1:
score: 10
Accepted
time: 1ms
memory: 5944kb
input:
9 1 3
output:
15
result:
ok single line: '15'
Test #2:
score: 10
Accepted
time: 0ms
memory: 5944kb
input:
12 2 2
output:
38
result:
ok single line: '38'
Test #3:
score: 10
Accepted
time: 1ms
memory: 6004kb
input:
22 1 1
output:
3287
result:
ok single line: '3287'
Test #4:
score: 10
Accepted
time: 0ms
memory: 6024kb
input:
47 15 7
output:
41
result:
ok single line: '41'
Test #5:
score: 10
Accepted
time: 1ms
memory: 6200kb
input:
94 2 38
output:
3664
result:
ok single line: '3664'
Test #6:
score: 10
Accepted
time: 4ms
memory: 8236kb
input:
378 1 2
output:
1398
result:
ok single line: '1398'
Test #7:
score: 10
Accepted
time: 5ms
memory: 9560kb
input:
680 271 72
output:
155
result:
ok single line: '155'
Test #8:
score: 10
Accepted
time: 16ms
memory: 11672kb
input:
973 14 23
output:
2535
result:
ok single line: '2535'
Test #9:
score: 10
Accepted
time: 4ms
memory: 9112kb
input:
800 500 141
output:
11
result:
ok single line: '11'
Test #10:
score: 10
Accepted
time: 12ms
memory: 11716kb
input:
998 1 1
output:
9017
result:
ok single line: '9017'