-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEXPWEI.java
52 lines (52 loc) · 1.3 KB
/
EXPWEI.java
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
47
48
49
50
51
52
import java.util.*;
import java.io.*;
class EXPWEI {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
long tc = sc.nextLong();
while(tc>0)
{
tc--;
long n = sc.nextLong();
long mod = 998244353, p=1,q=1;
if (n%2==0) {
if(n%4==0)
{
q=1;
p=n/4;
p%=mod;
p*=(n+1);
p%=mod;
p*=(n+1);
p%=mod;
}
if(n%2==0)
{
q=2;
p=n/2;
p%=mod;
p*=(n+1);
p%=mod;
p*=(n+1);
p%=mod;
}
}
else{
p*=(n+1)/2;
p%=mod;
p*=(n+1)/2;
p%=mod;
p*=n;
p%=mod;
}
long inv = 0 ;
if(q==1)
inv = 1;
if(q==2){
System.out.println(499122181);continue;}
long ans = p*inv;
ans%=mod;
System.out.println(ans);
}
}
}