ログイン
新規登録
AtsuoCoder Waseda Tour Finals 2025
読込中…
Home
Tasks
Clar
Submissions
Standings
提出 57afad2c-cbee-4fd5-8780-669afadd0e60
コード
#include<bits/stdc++.h> #include<atcoder/all> using namespace std; using namespace atcoder; using ll=long long; const ll inf=1e18,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==0) p.first+=p.second; if(p.first>MAX||p.second==0){ p.first=-1; p.second=MAX+2; } if(p.second>MAX+2) p.second=MAX+2; return p; } P e(){ return P(1,1); } 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; if(a==0) a+=b; seg.set(i,P(a,b)); } cin>>q; for(int i=0;i<q;i++){ cin>>l>>r; l--; cout<<seg.prod(l,r).first<<endl; } }
結果
問題
点数
言語
結果
実行時間
メモリ
I - Segment CRT
150
C++
AC
363 ms
8920 KiB