CF1521--A Nastia and Nearly Good Numbers

简介: CF1521--A Nastia and Nearly Good Numbers

image.png


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;
}
相关文章
|
10月前
CF1132D Stressful Training
CF1132D Stressful Training
|
机器学习/深度学习 人工智能
CF788A Functions again
CF788A Functions again
51 0
WRF模式报错:traj_opt is zero, but num_traj is not zero; setting num_traj to zero
最近,在跑WRF模式时遇到一个奇怪的问题,从WPS一直到WRF中运行./real.exe,全都没有问题,直到提交作业到集群上时发现,很短的时间内作业就结束了,而且只生成了一个时刻的数据,通过将debug_level调整到999发现,产生以下问题:
WRF模式报错:traj_opt is zero, but num_traj is not zero; setting num_traj to zero
TestRange.cs error CS0104: `Range' is an ambiguous reference between `System.Range' and Gtk.Range
TestRange.cs error CS0104: `Range' is an ambiguous reference between `System.Range' and Gtk.Range
148 0
CF1454 E. Number of Simple Paths (基环树 拓扑排序)
CF1454 E. Number of Simple Paths (基环树 拓扑排序)
73 0
|
Web App开发 测试技术
myAppointment OPA test case issue
myAppointment OPA test case issue
112 0
myAppointment OPA test case issue
Enterprise search debugging via test report in AG3
Created by Wang, Jerry, last modified on Dec 19, 2014
Enterprise search debugging via test report in AG3
GM6 pageset - DB get scenario
Created by Wang, Jerry, last modified on Apr 21, 2015
GM6 pageset - DB get scenario