zoukankan      html  css  js  c++  java
  • Codeforce |Educational Codeforces Round 77 (Rated for Div. 2) B. Obtain Two Zeroes

    B. Obtain Two Zeroes

    time limit per test
    1 second
    memory limit per test
    256 megabytes
    input
    standard input
    output
    standard output

    You are given two integers aa and bb. You may perform any number of operations on them (possibly zero).

    During each operation you should choose any positive integer xx and set a:=axa:=a−x, b:=b2xb:=b−2x or a:=a2xa:=a−2x, b:=bxb:=b−x. Note that you may choose different values of xx in different operations.

    Is it possible to make aa and bb equal to 00 simultaneously?

    Your program should answer tt independent test cases.

    Input

    The first line contains one integer tt (1t1001≤t≤100) — the number of test cases.

    Then the test cases follow, each test case is represented by one line containing two integers aa and bb for this test case (0a,b1090≤a,b≤109).

    Output

    For each test case print the answer to it — YES if it is possible to make aa and bb equal to 00 simultaneously, and NO otherwise.

    You may print every letter in any case you want (so, for example, the strings yEs, yes, Yes and YES will all be recognized as positive answer).

    Example
    input
    Copy
    3
    6 9
    1 1
    1 2
    
    output
    Copy
    YES
    NO
    YES
    
    Note

    In the first test case of the example two operations can be used to make both aa and bb equal to zero:

    1. choose x=4x=4 and set a:=axa:=a−x, b:=b2xb:=b−2x. Then a=64=2a=6−4=2, b=98=1b=9−8=1;
    2. choose x=1x=1 and set a:=a2xa:=a−2x, b:=bxb:=b−x. Then a=22=0a=2−2=0, b=11=0b=1−1=0.

    题解:

     CODE:

    #include<iostream>
    using namespace std;
    int m ,n;
    int main()
    {
        int t;
        cin>>t;
        for(int i=0;i<t;++i)
        {
            cin>>m>>n;
            if(m>n)swap(m,n);
            if((m+n)%3!=0||2*m<n)
            {
                cout<<"NO"<<endl;
            }
            else
            {
                cout<<"YES"<<endl;
            }
        }
        return 0;
     } 
  • 相关阅读:
    进程池的回调函数
    进程通信(multiprocessing.Queue)
    自动化批量管理工具salt-ssh
    自动化批量管理工具pssh
    Saltstack自动化操作记录(2)-配置使用
    Saltstack自动化操作记录(1)-环境部署
    RocketMQ 简单梳理 及 集群部署笔记
    CentOS7下单机部署RabbltMQ环境的操作记录
    centos6下ActiveMQ+Zookeeper消息中间件集群部署记录
    [Centos6.9下RabbitMQ集群部署记录]
  • 原文地址:https://www.cnblogs.com/chrysanthemum/p/11949491.html
Copyright © 2011-2022 走看看