This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/*
Author: AquaBlaze
Keqing best girl :)
Nephren will always be in my heart
*/
#include<bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define eb emplace_back
#define all(a) (a).begin(),(a).end()
#define SZ(a) (int)(a).size()
#define FOR(i, a, b) for(int i=(a); i<=(b); ++i)
#define ROF(i, a, b) for(int i=(a); i>=(b); --i)
#define make_unique(a) sort(all((a))), (a).resize(unique(all((a)))-(a).begin())
#define pc(x) putchar(x)
#define MP make_pair
#define MT make_tuple
using namespace std;
typedef long long i64;
typedef tuple<int,int,int> iii;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
const int N = 1000003, lg = 30;
int n;
i64 rem[N];
i64 x[N];
i64 A[N], B[N];
bool check(){
i64 p = 1;
FOR(i, 0, n-1){
x[0] = x[0]+rem[i]*p;
p *= 2;
}
x[0] *= -1;
if(x[0] < 0) return false;
if(x[0]%(p-1)) return false;
x[0] /= p-1;
FOR(i, 1, n-1){
x[i] = x[i-1]-rem[i-1];
if(x[i] < 0) return false;
if(x[i]%2) return false;
x[i]/=2;
}
return true;
}
void solve(){
cin >> n;
FOR(i, 0, n-1){
i64 a, b;
cin >> a >> b;
A[i] = a;
B[i] = b;
rem[i] = b-a;
}
if(check()){
puts("Yes"); return;
}
puts("No");
}
int main(){
solve();
return 0;
}
/*
*
*
*
*
*
*
*
*
*
*
*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |