QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#203617#6957. Do You Like Interactive Problems?Royo#AC ✓1ms3504kbC++20994b2023-10-06 18:42:262023-10-06 18:42:26

Judging History

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

  • [2023-10-06 18:42:26]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:3504kb
  • [2023-10-06 18:42:26]
  • 提交

answer

#include <bits/stdc++.h>
#include <cstdio>
#define int long long
#define PII pair<int, int>
#pragma GCC optimize("Ofast")
#define NO {puts("No") ; return ;}
#define YES {puts("Yes") ; return ;}
#define pb push_back
#define endl "\n"
#define fi first
#define se second
#define IOS std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
using namespace std;
mt19937 rd(time(0));
const int N = 1e5 + 10, mod = 998244353;

long long qmi(int a, int b, int p) {
    long long res = 1;
    while (b) {
        if (b & 1) res = res * a % p;
        a = a * (long long)a % p;
        b >>= 1;
    }
    
    return res;
}

long long inv(long long a, long long mod) {
    return qmi(a, mod - 2, mod);
}

void solve() {
	int n;
	cin >> n;
	if (n == 1)
	{
		cout << 0 << endl;
		return;
	}
	cout << (2 * n - 1) * qmi(3, mod - 2, mod) % mod << endl;

} 

signed main() {
    IOS;
    int t; cin >> t;
    while (t -- ) 
    solve();
    
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3504kb

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