Submission #66502


ソースコード

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
#include <bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
template <class A, class B> inline void chmod(A &a, const B b) { a = a%b; if (a<0) {a+=b;} return; }
template <class A, class B> inline A ceildiv(A a, const B b) { return a/b + (a%b != 0 ? 1 : 0); }
// template <class A, class B> inline A gcd(A a, B b) { if (a%b == 0) {return (b);} return (gcd(b, a%b)); }
const int MOD = 998244353;
long long gcd(long long a, long long b);
int main() {
int n, c;
long long k, a, ans;
cin >> n >> k;
c = 0;
for (int i=0; i<n; i++ ) {
cin >> a;
if(gcd(k, a) == 1) {
c++;
}
}
ans = 1;
for (int i=0; i<c; i++ ) {
ans = ans << 1;
chmod(ans, MOD);
}
ans--;
chmod(ans, MOD);
cout << ans << endl;
return (0);
}
long long gcd(long long a, long long b) {
if (a%b == 0) {
return (b);
}
return (gcd(b, a%b));
}

ステータス

項目 データ
問題 1409 - Prime Combination
ユーザー名 ei1929
投稿日時 2021-05-06 17:26:14
言語 C++17
状態 Accepted
得点 300
ソースコード長 1089 Byte
最大実行時間 191 ms
最大メモリ使用量 688 KB

セット

セット 得点 Cases
1 ALL 300 / 300 *

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
in01.txt AC 136 ms 604 KB
1
in02.txt AC 177 ms 580 KB
1
in03.txt AC 134 ms 416 KB
1
in04.txt AC 60 ms 648 KB
1
in05.txt AC 58 ms 492 KB
1
in06.txt AC 183 ms 468 KB
1
in07.txt AC 189 ms 568 KB
1
in08.txt AC 180 ms 544 KB
1
in09.txt AC 178 ms 516 KB
1
in10.txt AC 175 ms 616 KB
1
in11.txt AC 183 ms 468 KB
1
in12.txt AC 184 ms 440 KB
1
in13.txt AC 127 ms 540 KB
1
in14.txt AC 132 ms 512 KB
1
in15.txt AC 191 ms 480 KB
1
in16.txt AC 123 ms 576 KB
1
in17.txt AC 100 ms 548 KB
1
in18.txt AC 110 ms 516 KB
1
in19.txt AC 107 ms 620 KB
1
in20.txt AC 23 ms 592 KB
1
in21.txt AC 22 ms 688 KB
1
in22.txt AC 25 ms 532 KB
1
in23.txt AC 102 ms 504 KB
1
in24.txt AC 125 ms 608 KB
1
in25.txt AC 49 ms 580 KB
1
in26.txt AC 105 ms 548 KB
1
in27.txt AC 45 ms 644 KB
1
in28.txt AC 67 ms 616 KB
1
in29.txt AC 21 ms 588 KB
1
in30.txt AC 20 ms 564 KB
1
sample01.txt AC 22 ms 532 KB
1
sample02.txt AC 21 ms 500 KB
1