QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#714805 | #6736. Alice and Bob | MiniLong# | AC ✓ | 250ms | 160332kb | C++20 | 2.8kb | 2024-11-06 08:08:13 | 2024-11-06 08:08:13 |
Judging History
answer
#include <bits/stdc++.h>
#define _rep(i, x, y) for(int i = x; i <= y; ++i)
#define _req(i, x, y) for(int i = x; i >= y; --i)
#define _rev(i, u) for(int i = head[u]; i; i = e[i].nxt)
#define pb push_back
#define fi first
#define se second
#define mst(f, i) memset(f, i, sizeof f)
using namespace std;
#ifdef ONLINE_JUDGE
#define debug(...) 0
#else
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#endif
typedef long long ll;
typedef pair<int, int> PII;
namespace fastio{
#ifdef ONLINE_JUDGE
char ibuf[1 << 20],*p1 = ibuf, *p2 = ibuf;
#define get() p1 == p2 && (p2 = (p1 = ibuf) + fread(ibuf, 1, 1 << 20, stdin), p1 == p2) ? EOF : *p1++
#else
#define get() getchar()
#endif
template<typename T> inline void read(T &t){
T x = 0, f = 1;
char c = getchar();
while(!isdigit(c)){
if(c == '-') f = -f;
c = getchar();
}
while(isdigit(c)) x = x * 10 + c - '0', c = getchar();
t = x * f;
}
template<typename T, typename ... Args> inline void read(T &t, Args&... args){
read(t);
read(args...);
}
template<typename T> void write(T t){
if(t < 0) putchar('-'), t = -t;
if(t >= 10) write(t / 10);
putchar(t % 10 + '0');
}
template<typename T, typename ... Args> void write(T t, Args... args){
write(t), putchar(' '), write(args...);
}
template<typename T> void writeln(T t){
write(t);
puts("");
}
template<typename T> void writes(T t){
write(t), putchar(' ');
}
#undef get
};
using namespace fastio;
#define multitest() int T; read(T); _rep(tCase, 1, T)
namespace Calculation{
const ll mod = 998244353;
ll ksm(ll p, ll h){ll base = p % mod, res = 1; while(h){if(h & 1ll) res = res * base % mod; base = base * base % mod, h >>= 1ll;} return res;}
void dec(ll &x, ll y){x = ((x - y) % mod + mod) % mod;}
void add(ll &x, ll y){x = (x + y) % mod;}
void mul(ll &x, ll y){x = x * y % mod;}
ll sub(ll x, ll y){return ((x - y) % mod + mod) % mod;}
ll pls(ll x, ll y){return ((x + y) % mod + mod) % mod;}
ll mult(ll x, ll y){return x * y % mod;}
}
using namespace Calculation;
const int N = 1e7 + 5;
int n;
ll fac[N], ifac[N];
ll C(ll n, ll m){
if(n < m || m < 0) return 0;
if(n == m || !m) return 1;
return fac[n] * ifac[m] % mod * ifac[n - m] % mod;
}
int main(){
read(n);
fac[0] = ifac[0] = fac[1] = ifac[1] = 1;
_rep(i, 2, n) fac[i] = fac[i - 1] * i % mod, ifac[i] = (mod - mod / i) * ifac[mod % i] % mod;
_rep(i, 2, n) ifac[i] = ifac[i - 1] * ifac[i] % mod;
ll ans = 0;
_rep(i, 1, n) add(ans, C(n - i, i - 1) * fac[i - 1] % mod * fac[n - i] % mod);
writeln(ans);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 7720kb
input:
1
output:
1
result:
ok 1 number(s): "1"
Test #2:
score: 0
Accepted
time: 0ms
memory: 5672kb
input:
2
output:
1
result:
ok 1 number(s): "1"
Test #3:
score: 0
Accepted
time: 1ms
memory: 7700kb
input:
10
output:
997920
result:
ok 1 number(s): "997920"
Test #4:
score: 0
Accepted
time: 1ms
memory: 7704kb
input:
100
output:
188898954
result:
ok 1 number(s): "188898954"
Test #5:
score: 0
Accepted
time: 1ms
memory: 7592kb
input:
4
output:
10
result:
ok 1 number(s): "10"
Test #6:
score: 0
Accepted
time: 0ms
memory: 7708kb
input:
8
output:
12336
result:
ok 1 number(s): "12336"
Test #7:
score: 0
Accepted
time: 1ms
memory: 5664kb
input:
16
output:
373118483
result:
ok 1 number(s): "373118483"
Test #8:
score: 0
Accepted
time: 1ms
memory: 5660kb
input:
32
output:
314585464
result:
ok 1 number(s): "314585464"
Test #9:
score: 0
Accepted
time: 1ms
memory: 7728kb
input:
64
output:
627827331
result:
ok 1 number(s): "627827331"
Test #10:
score: 0
Accepted
time: 1ms
memory: 7780kb
input:
128
output:
828497685
result:
ok 1 number(s): "828497685"
Test #11:
score: 0
Accepted
time: 0ms
memory: 7724kb
input:
256
output:
65697890
result:
ok 1 number(s): "65697890"
Test #12:
score: 0
Accepted
time: 1ms
memory: 5680kb
input:
512
output:
854187619
result:
ok 1 number(s): "854187619"
Test #13:
score: 0
Accepted
time: 1ms
memory: 5572kb
input:
1024
output:
513823539
result:
ok 1 number(s): "513823539"
Test #14:
score: 0
Accepted
time: 20ms
memory: 28148kb
input:
1361956
output:
617368199
result:
ok 1 number(s): "617368199"
Test #15:
score: 0
Accepted
time: 186ms
memory: 127412kb
input:
7579013
output:
827172636
result:
ok 1 number(s): "827172636"
Test #16:
score: 0
Accepted
time: 189ms
memory: 134284kb
input:
8145517
output:
710624331
result:
ok 1 number(s): "710624331"
Test #17:
score: 0
Accepted
time: 137ms
memory: 104292kb
input:
6140463
output:
707600568
result:
ok 1 number(s): "707600568"
Test #18:
score: 0
Accepted
time: 63ms
memory: 65624kb
input:
3515281
output:
698302413
result:
ok 1 number(s): "698302413"
Test #19:
score: 0
Accepted
time: 159ms
memory: 113912kb
input:
6969586
output:
69470392
result:
ok 1 number(s): "69470392"
Test #20:
score: 0
Accepted
time: 50ms
memory: 54304kb
input:
2888636
output:
433579983
result:
ok 1 number(s): "433579983"
Test #21:
score: 0
Accepted
time: 248ms
memory: 160332kb
input:
9999998
output:
758172780
result:
ok 1 number(s): "758172780"
Test #22:
score: 0
Accepted
time: 233ms
memory: 159744kb
input:
9999999
output:
605195495
result:
ok 1 number(s): "605195495"
Test #23:
score: 0
Accepted
time: 250ms
memory: 160220kb
input:
10000000
output:
866813682
result:
ok 1 number(s): "866813682"