QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#856239 | #8147. Math Exam | gyydp123_LIM | AC ✓ | 152ms | 82020kb | C++20 | 1.5kb | 2025-01-13 19:32:24 | 2025-01-13 19:32:26 |
Judging History
answer
#include<bits/stdc++.h>
#define For(i,j,k) for(int i=(j);i<=(k);++i)
#define ForDown(i,j,k) for(int i=(j);i>=(k);--i)
#define Debug(fmt, args...) fprintf(stderr,"(func %s, line #%d): " fmt,__func__,__LINE__,##args),fflush(stderr)
#define debug(fmt, args...) fprintf(stderr,fmt,##args),fflush(stderr)
#define within :
#define LJY main
using namespace std;
typedef long long ll;
const int N=1e7+5,mod=998244353;
ll ksm(ll a,int k){ll s=1;while(k){if(k&1) s=s*a%mod;a=a*a%mod;k>>=1;}return s;}
mt19937 rnd(chrono::system_clock::now().time_since_epoch().count());
inline int read(){
char ch=getchar();int x=0,f=1;
while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
while(ch>='0'&&ch<='9')
x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
return x*f;
}
int fac[N],inv[N];
void reduce(int&x){x+=(x>>31)&mod;}
int calc(int x,int y){
if(x<0||y<0) return 0;
return (ll)fac[x+y]*inv[x]%mod*inv[y]%mod;
}
int f(int n,int m,int b,int c){
int res=calc(n,m),x=n,y=m;
while(x>=0&&y>=0){
swap(x,y);x-=b;y+=b;reduce(res-=calc(x,y));
swap(x,y);x-=c;y+=c;reduce(res+=calc(x,y)-mod);
}x=n,y=m;
while(x>=0&&y>=0){
swap(x,y);x-=c;y+=c;reduce(res-=calc(x,y));
swap(x,y);x-=b;y+=b;reduce(res+=calc(x,y)-mod);
}return res;
}
signed LJY(){
fac[0]=1;For(i,1,N-1) fac[i]=(ll)fac[i-1]*i%mod;
inv[N-1]=ksm(fac[N-1],mod-2);
ForDown(i,N-1,1) inv[i-1]=(ll)inv[i]*i%mod;
int n=read(),m=read(),ans=0;
For(i,0,(m+1)/2) if((i&1)==(n&1))
reduce(ans+=f((n-i)/2,(n+i)/2-1,-2,(m+1)/2)-mod);
printf("%lld\n",ans);
return 0;
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 87ms
memory: 81844kb
input:
9 13
output:
124
result:
ok answer is '124'
Test #2:
score: 0
Accepted
time: 85ms
memory: 81840kb
input:
500 999
output:
195157058
result:
ok answer is '195157058'
Test #3:
score: 0
Accepted
time: 152ms
memory: 81800kb
input:
10000000 19260817
output:
475124613
result:
ok answer is '475124613'
Test #4:
score: 0
Accepted
time: 91ms
memory: 81860kb
input:
1234567 654321
output:
986926700
result:
ok answer is '986926700'
Test #5:
score: 0
Accepted
time: 89ms
memory: 81876kb
input:
1145141 11451
output:
186897097
result:
ok answer is '186897097'
Test #6:
score: 0
Accepted
time: 89ms
memory: 81800kb
input:
114514 11451
output:
91839230
result:
ok answer is '91839230'
Test #7:
score: 0
Accepted
time: 90ms
memory: 81812kb
input:
1145143 114555
output:
641840034
result:
ok answer is '641840034'
Test #8:
score: 0
Accepted
time: 98ms
memory: 81864kb
input:
2123181 1980523
output:
784155222
result:
ok answer is '784155222'
Test #9:
score: 0
Accepted
time: 105ms
memory: 82020kb
input:
4238693 1876847
output:
169222558
result:
ok answer is '169222558'
Test #10:
score: 0
Accepted
time: 132ms
memory: 81820kb
input:
7804655 10519823
output:
935955279
result:
ok answer is '935955279'
Test #11:
score: 0
Accepted
time: 147ms
memory: 81904kb
input:
9189568 17055313
output:
811181659
result:
ok answer is '811181659'
Test #12:
score: 0
Accepted
time: 92ms
memory: 81912kb
input:
683534 1001003
output:
569208897
result:
ok answer is '569208897'
Test #13:
score: 0
Accepted
time: 99ms
memory: 81860kb
input:
1850342 3700683
output:
852266054
result:
ok answer is '852266054'
Test #14:
score: 0
Accepted
time: 119ms
memory: 81800kb
input:
10000000 1234567
output:
387622638
result:
ok answer is '387622638'
Test #15:
score: 0
Accepted
time: 84ms
memory: 81948kb
input:
1 1
output:
1
result:
ok answer is '1'
Test #16:
score: 0
Accepted
time: 82ms
memory: 82008kb
input:
3 1
output:
1
result:
ok answer is '1'
Test #17:
score: 0
Accepted
time: 105ms
memory: 81916kb
input:
10000000 1
output:
1
result:
ok answer is '1'
Extra Test:
score: 0
Extra Test Passed