Skip to content

Commit 0783d47

Browse files
authored
Update correct.cpp
1 parent 12ee19d commit 0783d47

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

pC/solution/correct.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ using namespace std;
44
const lli mod = 998244353;
55
lli n, m, q, mmod;
66
lli s[1000005], c[1000005];
7+
set<lli> ss;
78
bitset<(lli)1e6+5> np;
89
lli p[(lli)1e6+5], phi[(lli)1e6+5];
910
void sieve(lli n){
@@ -39,20 +40,21 @@ int main() {
3940
ios_base::sync_with_stdio(0);cin.tie(0);
4041
cin >> n >> m >> q;
4142
sieve(n);
42-
for(int i=1;i<=m;i++)cin >> c[i];
43+
for(int i=1;i<=m;i++){
44+
cin >> c[i];
45+
ss.insert(c[i]);
46+
}
4347
s[0]=s[1]=1;
4448
for(int i=1;i<=n;i++){
4549
lli tmp = 1;
46-
for(int j=1;j<=m;j++){
47-
tmp=tmp*fastpow(c[j], get(i, c[j]), mod)%mod;
48-
//cout << i << " and " << c[j] << " get " << get(i, c[j]) << endl;
50+
for(lli it : ss){
51+
tmp = tmp * fastpow(it, get(i, it), mod)%mod;
4952
}
50-
//cout << i << " " << tmp << endl;
5153
s[i]=s[i-1]*tmp%mod;
5254
}
5355
for(int i=1;i<=q;i++){
54-
int a, b;
55-
cin >> a >> b;
56-
cout << s[b]*fastpow(s[a-1], mod-2, mod)%mod << endl;
56+
int l, r;
57+
cin >> l >> r;
58+
cout << s[r]*fastpow(s[l-1], mod-2, mod)%mod << endl;
5759
}
5860
}

0 commit comments

Comments
 (0)