QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#834707 | #8147. Math Exam | xlwang | AC ✓ | 143ms | 81880kb | C++14 | 2.7kb | 2024-12-27 21:49:59 | 2024-12-27 21:49:59 |
Judging History
answer
#include<bits/stdc++.h>
#define ll long long
#define fr(i,j,k) for(register int i=j;i<=k;++i)
#define rf(i,j,k) for(register int i=j;i>=k;--i)
#define foredge(i,j) for(register int i=head[j];i;i=e[i].nxt)
#define pb push_back
#define Times printf("Time:%.3lf\n",clock()/CLOCKS_PER_SEC)
#define pii pair<int,int>
#define mk make_pair
using namespace std;
inline int read(){
int x=0;
bool f=0;
char c=getchar();
while(!isdigit(c)) f|=(c=='-'),c=getchar();
while(isdigit(c)) x=(x<<3)+(x<<1)+(c^48),c=getchar();
return f?-x:x;
}
inline void write(int x){
if(x<0){putchar('-');x=-x;}
if(x>9)write(x/10);
putchar(x%10+'0');
}
inline void writeln(int x){write(x); puts("");}
inline void writepl(int x){write(x); putchar(' ');}
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
inline int randfind(int l,int r){return rnd()%(r-l+1)+l;}
//inline void init(){
// int t=read();
// while(t--) work();
//}
const int Maxn=1e7+10,mod=998244353;
inline void add(int &x,int y){x+=y;if(x>=mod) x-=mod;}
inline int Add(int x,int y){x+=y;if(x>=mod) x-=mod;return x;}
inline int ksm(int x,int y=mod-2){
int sum=1;
while(y){
if(y&1) sum=1ll*sum*x%mod;
y=y/2;x=1ll*x*x%mod;
}return sum;
}
int fac[Maxn],ifac[Maxn];
inline int C(int x,int y){if(x<y || x<0 || y<0) return 0;return 1ll*fac[x]*ifac[y]%mod*ifac[x-y]%mod;}
int n,m;
inline void into(int N){
fac[0]=ifac[0]=1;
fr(i,1,N) fac[i]=1ll*fac[i-1]*i%mod;
ifac[N]=ksm(fac[N]);
rf(i,N-1,1) ifac[i]=1ll*ifac[i+1]*(i+1)%mod;
}
inline void init(){
n=read();m=read();m=(m+3)/2;into(1e7);
}
inline int F1(int x) {return -2-x;}
inline int F2(int x) {return m*2-x;}
inline void change(int &x,int op){
if(op==0) x=-2-x;
else x=m*2-x;
}
inline bool check(int x){
if(n+x<0 || n+x>2*n) return false;
return true;
}
inline int sgn(int x){
if(x==0) return mod-1;
return 1;
}
inline int getans(int x){
if((n+x)&1) return 0;
if(n+x<0 || n+x>2*n) return 0;
int i=x,op=0;
int ans=C(n,(n+x)/2);
while(1){
change(i,op);
if(!check(i)) break;
add(ans,1ll*sgn(op)*C(n,(n+i)/2)%mod);
op^=1;
}
i=x,op=1;
while(1){
change(i,op);
if(!check(i)) break;
add(ans,1ll*sgn(op^1)*C(n,(n+i)/2)%mod);
op^=1;
}
return ans;
}
inline void work(){
int ans=0;
fr(i,0,m-1){
add(ans,getans(i));
// cout<<i<<' '<<ans<<endl;
}
writeln(ans);
}
signed main(){
// freopen("input.in","r",stdin);
// freopen("output.out","w",stdout);
init();work();
// printf("\nTIME:%.3lf",(double)clock()/CLOCKS_PER_SEC);
return 0;
}
这程序好像有点Bug,我给组数据试试?
詳細信息
Test #1:
score: 100
Accepted
time: 78ms
memory: 81820kb
input:
9 13
output:
124
result:
ok answer is '124'
Test #2:
score: 0
Accepted
time: 89ms
memory: 81824kb
input:
500 999
output:
195157058
result:
ok answer is '195157058'
Test #3:
score: 0
Accepted
time: 143ms
memory: 81628kb
input:
10000000 19260817
output:
475124613
result:
ok answer is '475124613'
Test #4:
score: 0
Accepted
time: 92ms
memory: 81788kb
input:
1234567 654321
output:
986926700
result:
ok answer is '986926700'
Test #5:
score: 0
Accepted
time: 92ms
memory: 81804kb
input:
1145141 11451
output:
186897097
result:
ok answer is '186897097'
Test #6:
score: 0
Accepted
time: 90ms
memory: 81812kb
input:
114514 11451
output:
91839230
result:
ok answer is '91839230'
Test #7:
score: 0
Accepted
time: 88ms
memory: 81624kb
input:
1145143 114555
output:
641840034
result:
ok answer is '641840034'
Test #8:
score: 0
Accepted
time: 101ms
memory: 81804kb
input:
2123181 1980523
output:
784155222
result:
ok answer is '784155222'
Test #9:
score: 0
Accepted
time: 96ms
memory: 81804kb
input:
4238693 1876847
output:
169222558
result:
ok answer is '169222558'
Test #10:
score: 0
Accepted
time: 130ms
memory: 81792kb
input:
7804655 10519823
output:
935955279
result:
ok answer is '935955279'
Test #11:
score: 0
Accepted
time: 123ms
memory: 81840kb
input:
9189568 17055313
output:
811181659
result:
ok answer is '811181659'
Test #12:
score: 0
Accepted
time: 86ms
memory: 81808kb
input:
683534 1001003
output:
569208897
result:
ok answer is '569208897'
Test #13:
score: 0
Accepted
time: 92ms
memory: 81628kb
input:
1850342 3700683
output:
852266054
result:
ok answer is '852266054'
Test #14:
score: 0
Accepted
time: 131ms
memory: 81864kb
input:
10000000 1234567
output:
387622638
result:
ok answer is '387622638'
Test #15:
score: 0
Accepted
time: 86ms
memory: 81792kb
input:
1 1
output:
1
result:
ok answer is '1'
Test #16:
score: 0
Accepted
time: 81ms
memory: 81740kb
input:
3 1
output:
1
result:
ok answer is '1'
Test #17:
score: 0
Accepted
time: 123ms
memory: 81880kb
input:
10000000 1
output:
1
result:
ok answer is '1'
Extra Test:
score: 0
Extra Test Passed