ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#214790 | #2647. interval | naroto2022 | 100 | 5520ms | 29580kb | C++ | 1.7kb | 2024-11-21 20:50:55 | 2024-11-22 09:35:00 |
answer
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#define ll long long
#define ls p<<1
#define rs p<<1|1
using namespace std;
const int MN=5e5+5;
ll n,q,a[MN],op,l,r,k,ans;
struct tree{ll l,r,num;}t[MN<<2];
void write(ll n){if(n<0){putchar('-');write(-n);return;}if(n>9)write(n/10);putchar(n%10+'0');}
ll read(){ll 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;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
void build(ll p, ll l, ll r){
t[p].l=l;t[p].r=r;
if(l==r){
t[p].num=a[l];
return;
}
ll mid=l+r>>1;
build(ls,l,mid);build(rs,mid+1,r);
t[p].num=gcd(t[ls].num,t[rs].num);
}
void change(ll p, ll x, ll v){
if(t[p].l==t[p].r){
t[p].num=v;
return;
}
ll mid=t[p].l+t[p].r>>1;
if(x<=mid) change(ls,x,v);
else change(rs,x,v);
t[p].num=gcd(t[ls].num,t[rs].num);
}
void query(ll p, ll l, ll r, ll x){
if(ans>1) return;
if(t[p].num%x==0&&l<=t[p].l&&t[p].r<=r) return;
if(t[p].l==t[p].r){if(l<=t[p].l&&t[p].r<=r) ans++;return;}
ll mid=t[p].l+t[p].r>>1;
if(l<=mid&&t[ls].num%x) query(ls,l,r,x);
if(r>mid&&t[rs].num%x) query(rs,l,r,x);
}
int main(){
n=read();
for(int i=1; i<=n; i++) a[i]=read();
build(1,1,n);
q=read();while(q--){
op=read();
if(op==1){
l=read();r=read();k=read();ans=0;query(1,l,r,k);
if(ans==0||ans==1) printf("YES\n");
else printf("NO\n");
}
else{
l=read();k=read();
change(1,l,k);
}
}
return 0;
}
详细
小提示:点击横条可展开更详细的信息
Test #1:
score: 10
Accepted
time: 0ms
memory: 1556kb
input:
4794 52 364 910 468 13650 728 72 5 75 546 273 468 60 360 585 60 175 315 20475 350 18200 18 900 100 4...
output:
NO NO YES NO NO NO NO NO NO NO NO NO YES NO YES YES NO YES NO NO NO NO YES NO YES NO NO NO NO NO NO ...
result:
ok 2239 lines
Test #2:
score: 10
Accepted
time: 4ms
memory: 1548kb
input:
4601 117 42 16380 40 6300 84 18200 468 1820 30 4095 2520 2925 840 6552 900 78 273 450 3900 4680 6300...
output:
NO YES NO YES NO YES NO NO NO NO NO NO NO NO NO NO YES YES NO NO NO NO NO NO YES NO YES NO NO YES NO...
result:
ok 2466 lines
Test #3:
score: 10
Accepted
time: 656ms
memory: 29572kb
input:
493909 2340 163800 455 24 1638 130 14 1 182 4200 40 225 600 140 728 936 21 25 81900 520 1800 3 130 6...
output:
NO NO NO YES NO NO YES NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO YES NO NO NO NO NO NO NO NO NO N...
result:
ok 243064 lines
Test #4:
score: 10
Accepted
time: 768ms
memory: 29440kb
input:
477523 650 9 390 40950 39 1300 5850 600 1638 2184 936 260 16380 3900 1300 12600 11700 546 5 168 14 2...
output:
NO NO NO NO NO NO NO NO YES NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO YES NO...
result:
ok 243124 lines
Test #5:
score: 10
Accepted
time: 643ms
memory: 29572kb
input:
494330 7800 56 20 364 36 150 910 4550 780 280 936 163800 1400 8 130 56 936 700 84 14 450 325 650 360...
output:
NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO Y...
result:
ok 230459 lines
Test #6:
score: 10
Accepted
time: 661ms
memory: 29448kb
input:
477944 2184 182 105 75 42 3276 36 390 16380 2600 105 10 780 163800 21 504 182 312 13650 650 6552 234...
output:
YES NO NO NO NO NO NO NO YES YES NO YES NO NO NO NO NO NO YES NO NO NO NO NO NO NO NO NO NO NO YES N...
result:
ok 231178 lines
Test #7:
score: 10
Accepted
time: 694ms
memory: 29320kb
input:
461558 5460 36 2340 180 15 819 156 117 210 72 819 312 546 40 300 12600 200 1170 360 105 52 3 175 292...
output:
NO NO NO NO NO NO NO NO NO NO YES NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO ...
result:
ok 238940 lines
Test #8:
score: 10
Accepted
time: 688ms
memory: 29580kb
input:
495172 3900 6552 280 6825 35 630 18200 2275 1638 16380 210 45 75 2184 210 975 30 4 100 15 105 100 84...
output:
NO NO NO NO NO YES NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO YES NO NO NO NO NO NO NO NO NO NO NO...
result:
ok 239975 lines
Test #9:
score: 10
Accepted
time: 740ms
memory: 29488kb
input:
483384 27300 16380 350 200 364 84 210 1 35 6825 910 30 390 504 52 504 1575 350 315 4550 6825 18200 9...
output:
NO NO NO NO NO NO NO NO NO NO YES NO NO NO YES NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO...
result:
ok 239150 lines
Test #10:
score: 10
Accepted
time: 666ms
memory: 29228kb
input:
450191 20475 910 900 39 3 234 40950 3276 11700 175 50 140 1300 15 26 200 18 16380 180 7800 4680 4095...
output:
NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO N...
result:
ok 227345 lines