Codeforces Round #720 (Div. 2)-A.Nastia and Nearly Good Numbers-数学

Posted Chivas_/Regal

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Codeforces Round #720 (Div. 2)-A.Nastia and Nearly Good Numbers-数学相关的知识,希望对你有一定的参考价值。

题目:
在这里插入图片描述
思路:
我们易得在普通情况下,比a大比a * b小的a的倍数数都是差不多好的数,a * b是极好数
所以我们可以把a * b拆解为a和a * (b - 1),这样就可以得到两个由极好数拆解出来的差不多好数
但是我们要考虑两个情况
1.b = 1,此时不管怎么取,所有能被a整除的数都能被a * b整除,所以此时绝对是NO
2.b = 2,此时得到的两个差不多好数是相等的,所以我们把b变成4就行了

代码:

#include <algorithm>
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
#include <cstdio>
#include <stack>
#include <queue>
#include <cmath>
#include <map>
#include <set>
#define G 10.0
#define LNF 1e18
#define eps 1e-6
#define PI acos(-1.0)
#define ll long long
#define INF 0x7FFFFFFF
#define Regal exit(0)
#define Chivas int main()
#define pb(x) push_back(x)
#define SP system("pause")
#define rep(a, b, c) for(int a = b; a <= c; a ++)
#define ull unsigned long long
#define ALL(a) a.begin(),a.end()
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
#define IOS ios::sync_with_stdio(false)
#define MEM(a, b) memset(a, b, sizeof(a))
#define each_cass(cass) for (cin >> cass; cass; cass--)
#define test(a) cout << "---------" << a << "---------" << '\\n'
  
using namespace std;
 
inline void solve(){
    ll a, b;
    cin >> a >> b;
    if(b == 1){
        cout << "NO" << endl;
        return;
    }
    if(b == 2)  b = 4;
    cout << "YES" << endl;
    cout << a * (b - 1) << " " << a << " " << a * b << endl;
}
 
Chivas{
    int cass;
    each_cass(cass){
        solve();
    }
    Regal;
}

以上是关于Codeforces Round #720 (Div. 2)-A.Nastia and Nearly Good Numbers-数学的主要内容,如果未能解决你的问题,请参考以下文章

Codeforces Round #720 (Div. 2)Codeforces-1521ABC

Codeforces Round #720 (Div. 2) ABCDE题解

Codeforces Round #720 (div2) AB

Codeforces Round #720 (Div. 2), B. Nastia and a Good Array

Codeforces Round #720 (Div. 2) A. Nastia and Nearly Good Num

Codeforces Round #720 (Div. 2) A题解