每日一题:数数

题目

Solution


Code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <stdio.h>
typedef long long ll;
const ll mod = 998244353;
const ll M = 1e7;
ll t, n, ans1, ans2, x, p[M + 5];

ll qp(ll a, ll b)
{
ll ans = 1;
while (b)
{
if (b & 1)
ans = (ans * a) % mod;
a = (a * a) % mod;
b >>= 1;
}
return ans;
}

int main()
{
p[1] = 1;
for (ll i = 2; i <= M; i++)
p[i] = (p[i - 1] * i) % mod;
while (~scanf("%lld", &t))
{
while (t--)
{
scanf("%lld", &n);
ans1 = 0, ans2 = 1;
if (n & 1)
{
x = (n + 1) / 2;
ans1 = (((x * n) % mod) * ((x * n) % mod)) % mod;
}
else
{
x = n / 2;
ans1 = (((x * (n + 1)) % mod) * ((x * (n + 1)) % mod)) % mod;
}
ans2 = qp(p[n], 2 * n);
printf("%lld %lld\n", ans1, ans2);
}
}
return 0;
}
作者

Benboby

发布于

2020-08-11

更新于

2021-02-04

许可协议

Your browser is out-of-date!

Update your browser to view this website correctly.&npsb;Update my browser now

×