1260B - Obtain Two Zeroes - CodeForces Solution


binary search math *1300

Please click on ads to support us..

C++ Code:

#include <bits/stdc++.h>
using namespace std;

#define int long long
#define x first
#define y second
#define all(v) (v).begin(), (v).end()
#define all1(v) (v).begin() + 1, (v).end()
#define pb push_back
#define sz(x) (int)x.size()
typedef pair<int, int> PII;
typedef long long ll;
typedef unsigned long long ull;
const int inf = 1e9 + 7, mod = 998244353;
const ll linf = 9e18 + 7;
const int INF = 0x3f3f3f3f3f3f3f3f;
const int MAXINT = 2147483647;
const double PI = acos(-1);
#define i128 __int128
#define rep(i, n) for(int i = (0); i < (ll)(n); i++)
#define FL(i, l, r) for(int i = (ll)(l); i <= (ll)(r); i++)
#define FR(i, r, l) for(int i = (ll)(r); i <= (ll)(l); i--)
#define fix(x) cout << fixed << setprecision(x);
#define vc vector
// #define ll __int128
// inline void read(int &x)
// {
//     char c;int f=1;
//     while(!isdigit(c=getchar()))if(c=='-')f=-1;
//     x=(c&15);while(isdigit(c=getchar()))x=(x<<1)+(x<<3)+(c&15);
//     x*=f;
// }
// inline void read(ll &x)
// {
//     char c;int f=1;
//     while(!isdigit(c=getchar()))if(c=='-')f=-1;
//     x=(c&15);while(isdigit(c=getchar()))x=(x<<1)+(x<<3)+(c&15);
//     x*=f;
// }
// 输出__int128
// void print(ll x)
// {
//     if(x < 0) putchar('-'), x = -x;
//     if(x > 9) print(x / 10);
//     putchar(x % 10 + '0');
// }

template<typename T1>
void print(vector<T1> &v, bool OutSize = false, bool isendl = false)
{
    if(OutSize) cout << v.size() << '\n';
    for(auto &t : v) cout << t << (isendl ? '\n' : ' ');
    if(!isendl) cout << '\n';
}

template<typename T2>
void pr(T2 x)
{
    cout << x << endl;
}

int min(int a, int b)
{
    if(a <= b) return a;
    return b;
}

int max(int a, int b)
{
    if(a >= b) return a;
    return b;
}

bool is_prime(int x)
{
    if(x < 2) return false;
    for(int i = 2; i <= x / i; i++)
        if(x % i == 0) return false;
    return true;
}

int qmi(int a, int k, int p)
{
    a %= p;
    int res = 1;
    while(k)
    {
        if(k & 1) res = res * a % p;
        a = a * a % p;
        k >>= 1;
    }
    return res;
}

vector<int> gi(int n)
{
    vector<int> v(n);
    for(int i = 0; i < n; i++) cin >> v[i];
    return v;
}

vector<int> gi1(int n)
{
    vector<int> v(n + 1);
    for(int i = 1; i <= n; i++) cin >> v[i];
    return v;
}

//--------------------------// A C //--------------------------------------

void solve()
{   
    int a, b;
    cin >> a >> b;
    if(a > b) swap(a, b); 
    if((a + b) % 3 == 0 && a * 2 >= b) pr("YES");
    else pr("NO");
}    

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin >> t;
    while(t--)
        solve();
}


Comments

Submit
0 Comments
More Questions

1466C - Canine poetry
74A - Room Leader
1333D - Challenges in school №41
1475B - New Year's Number
461A - Appleman and Toastman
320B - Ping-Pong (Easy Version)
948A - Protect Sheep
387A - George and Sleep
53A - Autocomplete
1729G - Cut Substrings
805B - 3-palindrome
805C - Find Amir
676C - Vasya and String
1042B - Vitamins
1729F - Kirei and the Linear Function
25D - Roads not only in Berland
1694A - Creep
659F - Polycarp and Hay
1040A - Palindrome Dance
372A - Counting Kangaroos is Fun
1396B - Stoned Game
16A - Flag
1056A - Determine Line
670B - Game of Robots
1418C - Mortal Kombat Tower
1382B - Sequential Nim
1272C - Yet Another Broken Keyboard
808A - Lucky Year
1245A - Good ol' Numbers Coloring
58B - Coins