QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#715715#6957. Do You Like Interactive Problems?hejinming983282#AC ✓0ms3704kbC++231.1kb2024-11-06 13:09:182024-11-06 13:09:19

Judging History

你现在查看的是最新测评结果

  • [2024-11-06 13:09:19]
  • 评测
  • 测评结果:AC
  • 用时:0ms
  • 内存:3704kb
  • [2024-11-06 13:09:18]
  • 提交

answer

// Author : hejinming2012
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define dbg(x) cout << #x " = " << (x) << endl
#define quickio ios::sync_with_stdio(false);
#define quickin cin.tie(0);
#define quickout cout.tie(0);
#define mod 998244353
using namespace std;
inline int read() {
    int now = 0, nev = 1; char c = getchar();
    while(c < '0' || c > '9') { if(c == '-') nev = -1; c = getchar(); }
    while(c >= '0' && c <= '9') { now = (now << 1) + (now << 3) + (c & 15); c = getchar(); }
    return now * nev;
}
void write(int x) {
    if(x < 0) putchar('-'), x = -x;
    if(x > 9) write(x / 10);
    putchar(x % 10 + '0');
}
int qpow(int x, int y) {
    int res = 1;
    while(y) {
        if(y & 1) res = res * x % mod;
        x = x * x % mod, y >>= 1;
    }
    return res;
}
signed main() {
    quickio
    quickin
    quickout
    int T = read();
    while(T--) {
        int n = read();
        if(n == 1) write(0), putchar(10);
        else write((2 * n - 1) % mod * qpow(3, mod - 2) % mod), putchar(10);
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3704kb

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