QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#310087 | #8147. Math Exam | bachbeo2007 | AC ✓ | 128ms | 159876kb | C++23 | 2.3kb | 2024-01-21 01:23:52 | 2024-01-21 01:23:54 |
Judging History
answer
// Judges with GCC >= 12 only needs Ofast
// #pragma GCC optimize("O3,no-stack-protector,fast-math,unroll-loops,tree-vectorize")
// MLE optimization
// #pragma GCC optimize("conserve-stack")
// Old judges
// #pragma GCC target("sse4.2,popcnt,lzcnt,abm,mmx,fma,bmi,bmi2")
// New judges. Test with assert(__builtin_cpu_supports("avx2"));
// #pragma GCC target("avx2,popcnt,lzcnt,abm,bmi,bmi2,fma,tune=native")
// Atcoder
// #pragma GCC target("avx2,popcnt,lzcnt,abm,bmi,bmi2,fma")
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
- insert(x),erase(x)
- find_by_order(k): return iterator to the k-th smallest element
- order_of_key(x): the number of elements that are strictly smaller
*/
#include<bits/stdc++.h>
using namespace std;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
uniform_real_distribution<> pp(0.0,1.0);
#define int long long
#define ld long double
#define pii pair<int,int>
#define piii pair<pii,int>
#define mpp make_pair
#define fi first
#define se second
const int inf=1e18;
const int mod=998244353;
const int maxn=10000005;
const int bl=650;
const int maxs=655;
const int maxm=200005;
const int maxq=1000005;
const int maxl=25;
const int maxa=1000000;
const int root=3;
int power(int a,int n){
int res=1;
while(n){
if(n&1) res=res*a%mod;
a=a*a%mod;n>>=1;
}
return res;
}
const int iroot=power(3,mod-2);
const int base=101;
int fac[maxn],dfac[maxn];
int C(int k,int n){
if(k>n) return 0;
return fac[n]*dfac[k]%mod*dfac[n-k]%mod;
}
void combi(int n){
fac[0]=1;
for(int i=1;i<=n;i++) fac[i]=fac[i-1]*i%mod;
dfac[n]=power(fac[n],mod-2);
for(int i=n;i>=1;i--) dfac[i-1]=dfac[i]*i%mod;
}
void solve(){
int n,m;cin >> n >> m;
m=(m+1)/2;m+=2;
combi(n);
int res=0;
for(int i=0;i<=n;i++){
int cnt=C(i,n);
int s=2*i-n;
if((s+1)%m==0) continue;
int d=(s+1)/m+(s<0);
if(d&1) res=(res+mod-cnt)%mod;
else res=(res+cnt)%mod;
}
cout << res << '\n';
}
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);cout.tie(NULL);
int test=1;//cin >> test;
while(test--) solve();
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3572kb
input:
9 13
output:
124
result:
ok answer is '124'
Test #2:
score: 0
Accepted
time: 1ms
memory: 3584kb
input:
500 999
output:
195157058
result:
ok answer is '195157058'
Test #3:
score: 0
Accepted
time: 124ms
memory: 159812kb
input:
10000000 19260817
output:
475124613
result:
ok answer is '475124613'
Test #4:
score: 0
Accepted
time: 23ms
memory: 23988kb
input:
1234567 654321
output:
986926700
result:
ok answer is '986926700'
Test #5:
score: 0
Accepted
time: 17ms
memory: 21588kb
input:
1145141 11451
output:
186897097
result:
ok answer is '186897097'
Test #6:
score: 0
Accepted
time: 3ms
memory: 5536kb
input:
114514 11451
output:
91839230
result:
ok answer is '91839230'
Test #7:
score: 0
Accepted
time: 18ms
memory: 21516kb
input:
1145143 114555
output:
641840034
result:
ok answer is '641840034'
Test #8:
score: 0
Accepted
time: 27ms
memory: 36868kb
input:
2123181 1980523
output:
784155222
result:
ok answer is '784155222'
Test #9:
score: 0
Accepted
time: 50ms
memory: 69784kb
input:
4238693 1876847
output:
169222558
result:
ok answer is '169222558'
Test #10:
score: 0
Accepted
time: 96ms
memory: 125568kb
input:
7804655 10519823
output:
935955279
result:
ok answer is '935955279'
Test #11:
score: 0
Accepted
time: 128ms
memory: 147200kb
input:
9189568 17055313
output:
811181659
result:
ok answer is '811181659'
Test #12:
score: 0
Accepted
time: 3ms
memory: 14372kb
input:
683534 1001003
output:
569208897
result:
ok answer is '569208897'
Test #13:
score: 0
Accepted
time: 25ms
memory: 32468kb
input:
1850342 3700683
output:
852266054
result:
ok answer is '852266054'
Test #14:
score: 0
Accepted
time: 127ms
memory: 159856kb
input:
10000000 1234567
output:
387622638
result:
ok answer is '387622638'
Test #15:
score: 0
Accepted
time: 1ms
memory: 3668kb
input:
1 1
output:
1
result:
ok answer is '1'
Test #16:
score: 0
Accepted
time: 1ms
memory: 3692kb
input:
3 1
output:
1
result:
ok answer is '1'
Test #17:
score: 0
Accepted
time: 127ms
memory: 159876kb
input:
10000000 1
output:
1
result:
ok answer is '1'
Extra Test:
score: 0
Extra Test Passed