QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#196294 | #6957. Do You Like Interactive Problems? | yiyiyi# | AC ✓ | 0ms | 3564kb | C++14 | 724b | 2023-10-01 15:21:14 | 2023-10-01 15:21:15 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
#define inf 0x3f3f3f3f
#define re register
#define N 1020030
#define pii pair<int,int>
#define fi first
#define se second
using namespace std;
const int mo=998244353;
inline int read(){
int x=0,w=0;char ch=getchar();
while (!isdigit(ch))w|=ch=='-',ch=getchar();
while (isdigit(ch))x=(x<<1)+(x<<3)+ch-'0',ch=getchar();
return w?-x:x;
}
int ksm(int x,int p){
int res=1;
for (;p;p>>=1){
if (p&1)res=res*x%mo;
x=x*x%mo;
}
return res;
}
void solve(){
int n=read();
if (n==1){puts("0");return;}
cout<<(n+(n-2)*2%mo*n%mo*ksm(3,mo-2)%mo)*ksm(n,mo-2)%mo<<endl;
}
signed main(){
int T=read();
while (T--)solve();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3564kb
input:
100 251608761 33782011 325968940 486286497 999999993 575267221 8 928380304 123861349 739740016 999999991 31193142 9 999999996 705831120 162816569 293889735 644068367 999999992 1 323447272 387107234 6 214616549 755303220 699413097 499430423 151674815 999999998 46590460 2486352 926437790 248790470 100...
output:
833235409 355269458 550060744 989687233 333918544 716259598 5 951668320 415322350 825908128 1170425 686291663 665496241 333918546 137805962 108544379 861422725 429378911 666666661 0 548379632 258071489 665496239 143077699 170787362 133527280 332953615 101116543 666666665 363808424 667153803 61762519...
result:
ok 100 lines