QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#839367 | #1089. Biological Software Utilities | ASnown | AC ✓ | 5ms | 7452kb | C++17 | 3.6kb | 2025-01-01 17:36:20 | 2025-01-01 17:36:20 |
Judging History
answer
#include<bits/stdc++.h>
#define file(F) freopen(#F".in","r",stdin),freopen(#F".out","w",stdout)
#define lowbit(x) ((x)&-(x))
#define ALL(x) (x).begin(),(x).end()
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define popc(x) (__builtin_popcountll((x)))
#define abs(x) ((x)>=0?(x):-(x))
using namespace std;
using ll=long long;
using uint=uint32_t;
namespace asnown {
using i32=int32_t; using u32=uint32_t;
using i64=int64_t; using u64=uint64_t;
using i128=__int128_t; using u128=__uint128_t; };
template<typename T>
inline bool Max(T &x,T y) { return std::less<T>()(x,y)&&(x=y,true); }
template<typename T>
inline bool Min(T &x,T y) { return std::less<T>()(y,x)&&(x=y,true); }
void Solve();
namespace asnown {
constexpr i32 inverse(i32 a,i32 m) { i64 r=1;
for(;a>1;a=m%a) r=r*(m-m/a)%m; return r; }
template<i32 m>
class static_modint {
using mint=static_modint;
public:
constexpr static_modint() : v(0) {}
constexpr static_modint(i32 v) : v(normal(v%m)) {}
constexpr static_modint(u32 v) : v(v%m) {}
constexpr static_modint(i64 v) : v(normal(v%m)) {}
constexpr static_modint(u64 v) : v(v%m) {}
constexpr static_modint(i128 v) : v(normal(v%m)) {}
constexpr static_modint(u128 v) : v(v%m) {}
constexpr u32 normal(i32 v) { if(v>=m) v-=m; return v+((v>>31)&m); }
constexpr u32 val() const { return v; }
constexpr static u32 mod() { return m; }
constexpr explicit operator bool() const { return v; }
constexpr mint inv() const { assert(v!=0); return mint(inverse(v,m)); }
constexpr mint pow(i64 b) const { assert(b>=0);
mint a=*this,res=1; for(;b;b>>=1,a*=a) if(b&1) res*=a; return res; }
constexpr mint operator+() const { return *this; }
constexpr mint operator-() const { return mint()-*this; }
constexpr mint& operator+=(const mint &p) { return v=normal(v+p.v),*this; }
constexpr mint& operator-=(const mint &p) { return v=normal(v-p.v),*this; }
constexpr mint& operator++() { return (*this)+=1; }
constexpr mint& operator--() { return (*this)-=1; }
constexpr mint& operator++(i32) { auto tmp=*this; return ++*this,tmp; }
constexpr mint& operator--(i32) { auto tmp=*this; return --*this,tmp; }
constexpr mint& operator*=(const mint &p) { v=i64(v)*p.v%m; return *this; }
constexpr mint& operator/=(const mint &p) { return *this *= p.inv(); }
constexpr friend mint operator+(const mint &p,const mint &q) { return mint(p)+=q; }
constexpr friend mint operator-(const mint &p,const mint &q) { return mint(p)-=q; }
constexpr friend mint operator*(const mint &p,const mint &q) { return mint(p)*=q; }
constexpr friend mint operator/(const mint &p,const mint &q) { return mint(p)/=q; }
constexpr friend std::istream& operator>>(std::istream &is,mint &a) { i64 v; is>>v; a=v; return is; }
constexpr friend std::ostream& operator<<(std::ostream &os,const mint &a) { os<<a.val(); return os; }
constexpr bool operator==(const mint& p) const { return val()==p.val(); }
constexpr bool operator!=(const mint& p) const { return val()!=p.val(); }
private:
u32 v;
};
using modint998244353=static_modint<998244353>;
using modint107=static_modint<1000000007>;
};
using mint=asnown::modint998244353;
const int N = 1e6+16;
mint fac[N];
signed main() {
#ifndef ONLINE_JUDGE
#endif
cin.tie(nullptr)->sync_with_stdio(false);
Solve();
}
void Solve() {
int n; cin>>n;
if(n&1) return void(puts("0"));
if(n==2) return void(puts("1"));
fac[0]=1; for(int i=1;i<=n;i++) fac[i]=fac[i-1]*i;
mint ans=fac[n]/fac[n/2]/mint(2).pow(n/2);
ans*=mint(n/2).pow(n/2-2);
ans*=mint(4).pow(n/2-1);
cout<<ans<<endl;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3500kb
input:
1
output:
0
result:
ok 1 number(s): "0"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3496kb
input:
2
output:
1
result:
ok 1 number(s): "1"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3564kb
input:
3
output:
0
result:
ok 1 number(s): "0"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3564kb
input:
4
output:
12
result:
ok 1 number(s): "12"
Test #5:
score: 0
Accepted
time: 0ms
memory: 3572kb
input:
7788
output:
178152092
result:
ok 1 number(s): "178152092"
Test #6:
score: 0
Accepted
time: 5ms
memory: 7396kb
input:
1000000
output:
178454094
result:
ok 1 number(s): "178454094"
Test #7:
score: 0
Accepted
time: 0ms
memory: 3536kb
input:
12346
output:
751958800
result:
ok 1 number(s): "751958800"
Test #8:
score: 0
Accepted
time: 0ms
memory: 7452kb
input:
999996
output:
690785929
result:
ok 1 number(s): "690785929"
Test #9:
score: 0
Accepted
time: 0ms
memory: 3548kb
input:
6
output:
720
result:
ok 1 number(s): "720"
Test #10:
score: 0
Accepted
time: 0ms
memory: 3552kb
input:
10
output:
30240000
result:
ok 1 number(s): "30240000"
Test #11:
score: 0
Accepted
time: 0ms
memory: 3704kb
input:
99
output:
0
result:
ok 1 number(s): "0"
Test #12:
score: 0
Accepted
time: 0ms
memory: 3476kb
input:
100
output:
934178078
result:
ok 1 number(s): "934178078"
Test #13:
score: 0
Accepted
time: 0ms
memory: 3588kb
input:
20
output:
245111072
result:
ok 1 number(s): "245111072"
Test #14:
score: 0
Accepted
time: 0ms
memory: 3564kb
input:
38745
output:
0
result:
ok 1 number(s): "0"
Test #15:
score: 0
Accepted
time: 0ms
memory: 3636kb
input:
3848
output:
928659530
result:
ok 1 number(s): "928659530"
Test #16:
score: 0
Accepted
time: 0ms
memory: 3488kb
input:
347835
output:
0
result:
ok 1 number(s): "0"
Test #17:
score: 0
Accepted
time: 2ms
memory: 4460kb
input:
234234
output:
745247398
result:
ok 1 number(s): "745247398"
Test #18:
score: 0
Accepted
time: 0ms
memory: 3548kb
input:
12
output:
818069491
result:
ok 1 number(s): "818069491"
Test #19:
score: 0
Accepted
time: 0ms
memory: 3548kb
input:
98
output:
648803799
result:
ok 1 number(s): "648803799"
Test #20:
score: 0
Accepted
time: 0ms
memory: 3700kb
input:
124
output:
159487965
result:
ok 1 number(s): "159487965"
Test #21:
score: 0
Accepted
time: 0ms
memory: 3620kb
input:
1024
output:
318674437
result:
ok 1 number(s): "318674437"
Test #22:
score: 0
Accepted
time: 3ms
memory: 6560kb
input:
524288
output:
495260023
result:
ok 1 number(s): "495260023"
Test #23:
score: 0
Accepted
time: 0ms
memory: 3564kb
input:
524289
output:
0
result:
ok 1 number(s): "0"
Test #24:
score: 0
Accepted
time: 0ms
memory: 3492kb
input:
999999
output:
0
result:
ok 1 number(s): "0"
Test #25:
score: 0
Accepted
time: 0ms
memory: 3532kb
input:
999997
output:
0
result:
ok 1 number(s): "0"