ログイン
新規登録
AtsuoCoder Waseda Tour Finals 2025
読込中…
Home
Tasks
Clar
Submissions
Standings
提出 c43d46b2-e73e-4e95-a0bd-7d30e561ef8f
コード
#include<bits/stdc++.h> #include<atcoder/all> using namespace std; using namespace atcoder; using ll=long long; const ll MAX=(1ll<<31)-1; using P=pair<ll,ll>; P op(P a,P b){ P p=crt({a.first,b.first},{a.second,b.second}); if(p.first>MAX||p.second==0){ p.first=MAX+1; p.second=MAX+2; } if(p.second>MAX+2) p.second=MAX+2; return p; } P e(){ return P(1,0); } int main(){ int n,a,b,q,l,r; cin>>n; segtree<P,op,e>seg(n); for(int i=0;i<n;i++){ cin>>a>>b; seg.set(i,P(a,b)); } cin>>q; for(int i=0;i<q;i++){ cin>>l>>r; l--; P p=seg.prod(l,r); if(p.first==0) p.first=p.second; if(p.first>MAX) cout<<-1<<endl; else cout<<p.first<<endl; } }
結果
問題
点数
言語
結果
実行時間
メモリ
I - Segment CRT
0
C++
RE
103 ms
9388 KiB