zoukankan      html  css  js  c++  java
  • A. Prime Subtraction ( Educational Codeforces Round 74 (Rated for Div. 2) )

    You are given two integers xx and yy (it is guaranteed that x>yx>y). You may choose any prime integer pp and subtract it any number of times from xx. Is it possible to make xx equal to yy?

    Recall that a prime number is a positive integer that has exactly two positive divisors: 11 and this integer itself. The sequence of prime numbers starts with 22, 33, 55, 77, 1111.

    Your program should solve tt independent test cases.

    Input

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

    Then tt lines follow, each describing a test case. Each line contains two integers xx and yy (1y<x10181≤y<x≤1018).

    Output

    For each test case, print YES if it is possible to choose a prime number pp and subtract it any number of times from xx so that xx becomes equal to yy. Otherwise, print NO.

    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
    4
    100 98
    42 32
    1000000000000000000 1
    41 40
    
    output
    Copy
    YES
    YES
    YES
    NO
    
    Note

    In the first test of the example you may choose p=2p=2 and subtract it once.

    In the second test of the example you may choose p=5p=5 and subtract it twice. Note that you cannot choose p=7p=7, subtract it, then choose p=3p=3 and subtract it again.

    In the third test of the example you may choose p=3p=3 and subtract it 333333333333333333333333333333333333 times.

    特判0,1。

    因为任何一个数都可以由 2 或者 2+1 组成,所以直接判断就行

    int main()
    {
        int t;
        cin>>t;
        while(t--)
        {
            cin>>n>>m;
            if(n==m || n==m+1) cout<<"NO"<<endl;
            else if((n-m)%2==0 ||(n-m)%3==0||(n-m)%5==0||(n-m)%7==0 )
                cout<<"YES"<<endl;
        }
    }
    所遇皆星河
  • 相关阅读:
    PHP关于VC11,VC9,VC6以及Thread Safe和Non Thread Safe版本选择的问题
    团队展示
    测试与优化:设计模式的应用和初次尝试多线程
    结对编程,三年级混合运算
    一个大气又可爱的标题
    随笔
    C#操作word类文件
    TypeError: Object of type 'int32' is not JSON serializable ——已解决
    Error: UserWarning: Ignoring URL... 已解决
    tensorflow(二)----线程队列与io操作
  • 原文地址:https://www.cnblogs.com/Shallow-dream/p/11650729.html
Copyright © 2011-2022 走看看