File tree Expand file tree Collapse file tree 1 file changed +10
-8
lines changed Expand file tree Collapse file tree 1 file changed +10
-8
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ using namespace std;
44const lli mod = 998244353 ;
55lli n, m, q, mmod;
66lli s[1000005 ], c[1000005 ];
7+ set<lli> ss;
78bitset<(lli)1e6 +5 > np;
89lli p[(lli)1e6 +5 ], phi[(lli)1e6 +5 ];
910void 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}
You can’t perform that action at this time.
0 commit comments