input
3
5 3
13 2
7 11
output
YES
10 50 60
YES
169 39 208
YES
28 154 182
Note
In the first test case: 60 — good number; 10 and 50 — nearly good numbers.
In the second test case: 208 — good number; 169 and 39 —nearly good numbers.
In the third test case: 154 — good number; 28 and 182 — nearly good numbers.
思路:题目的意思是如果能被A*B整除则是好数,如果仅能被A不能被B整除则是个较好数。
给出俩数A,B. 构建x+y = z.满足其中一个是好数,另外两个是较好数。
三个数都能被A整除。 A AB 我们想到了 A+AB=A *(B+1).所以如果存在则该式子必成立.
哪种情况不存在呢?A都能被除,那么B呢,假如说B都能被三个数整除,那三个数肯定不满足一个好,两个较好的条件了。观察可知,但B=1时,三个数都能被B整除。所以思路就有了。
参考代码
#include<bits/stdc++.h>
using namespace std;
int t,m,n;
int main()
{
cin>>t;
while(t--){
cin>>m>>n;
if(n==1){
cout<<"NO"<<endl;
}else{
cout<<"YES"<<endl;
cout<<m<<" "<<(long long)m*n<<" "<<(long long)m*(n+1)<<endl;
}
}
return 0;
}