天天看點

A. Nastia and Nearly Good Numbers【1000 / 思維 構造】

A. Nastia and Nearly Good Numbers【1000 / 思維 構造】

https://codeforces.com/problemset/problem/1521/A

幾乎好的數是

x%a==0 && x%(a*b)!=0

好的數是

x%(a*b)==0

是以如果b==1 那麼結果一定不存在

A(a+b)=ABc

a+b=B*c

讓c等于1,剩下的數随便分B

當B=2時乘以2 一個分1 一個分3即可。

#include<bits/stdc++.h>
using namespace std;
typedef long long int LL;
int main(void)
{
	int t; cin>>t;
	while(t--)
	{
		LL a,b; cin>>a>>b;
		if(b==1) puts("NO");
		else 
		{
			puts("YES");
			if(b==2)  cout<<a<<" "<<a*3<<" "<<a*b*2<<endl;
			else cout<<a<<" "<<a*(b-1)<<" "<<a*b<<endl;
		}	
	}
	return 0;
}
           

繼續閱讀