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 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
| #include<bits/stdc++.h>
using namespace std; #ifdef LOCAL #define debug(...) fprintf(stdout, ##__VA_ARGS__) #define debag(...) fprintf(stderr, ##__VA_ARGS__) #else #define debug(...) void(0) #define debag(...) void(0) #endif
inline int read(){int x=0,f=1;char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')f=-1; ch=getchar();}while(ch>='0'&&ch<='9'){x=(x<<1)+ (x<<3)+(ch^48);ch=getchar();}return x*f;} #define Z(x) (x)*(x) #define pb push_back #define fi first #define se second #define M 62 #define mo 19961993 #define N 100010 int pw(int a, int b) { int ans = 1; while(b) { if(b & 1) ans = 1ll * ans * a % mo; a = 1ll * a * a % mo; b >>= 1;
} return ans; } int pw(int a) { return pw(a, mo - 2); } int n, m, i, j, k, T; int a[N][M], op, l, r, ans, p[M], ns[N];
struct Bin1 { int cnt[N]; void add(int x, int y) { while(x <= m) cnt[x] += y, x += x & -x; } int qry(int x) { int ans = 0; if(!x) return 0; while(x) ans += cnt[x], x -= x & -x; return ans; } }B1[M];
void Mul(int &x, int y) { x = 1ll * x * y % mo; }
struct Bin2 { int cnt[N]; void init() { for(int i = 0; i < N; ++i) cnt[i] = 1; } void add(int x, int y) { while(x <= m) Mul(cnt[x], y), x += x & -x; } int qry(int x) { int ans = 1; if(!x) return 1; while(x) Mul(ans, cnt[x]), x -= x & -x; return ans; } }B2;
signed main() { #ifdef LOCAL freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout); #endif
for(i = 2; ; ++i) { for(j = 2; j < i; ++j) if(i % j == 0) break; if(j == i) p[++k] = i, ns[k] = pw(p[k]); if(k > 60) break; } T = read(); m = 1e5; B2.init(); for(i = 1; i <= m; ++i) B1[2].add(i, 1), B2.add(i, 3), a[i][0] = 3, a[i][2] = 1; while(T--) { op = read(); l = read(); r = read(); if(op == 0) { ans = 1ll * B2.qry(r) * pw(B2.qry(l - 1)) % mo; for(i = 1; i <= 60; ++i) { k = B1[i].qry(r) ; if(k) k -= B1[i].qry(l - 1); if(k) Mul(ans, p[i] - 1), Mul(ans, ns[i]); } printf("%d\n", ans); } if(op == 1) { B2.add(l, pw(a[l][0])); a[l][0] = r; B2.add(l, r); for(i = 1; i <= 60; ++i) { k = (r % p[i] == 0); if(a[l][i] != k) B1[i].add(l, -a[l][i] + k); a[l][i] = k; } } } return 0; }
|