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;
}
相关文章
|
4月前
|
Linux 开发工具
You could try using --skip-broken to work around the problem You could try running: rpm -Va --nofi
linux配置环境变量操作失误出现:/usr/libexec/grepconf.sh: line 5: grep: command not found 的解决办法
90 2
|
5月前
No rule to make target ‘.xxxxxxxx‘, needed by ‘debug/xxxx.cpp‘. Stop.
No rule to make target ‘.xxxxxxxx‘, needed by ‘debug/xxxx.cpp‘. Stop.
|
6月前
|
IDE 开发工具 Android开发
Couldn‘t get post build model. Module:UpdateService_0804.main Variant: debugOpen logcat panel fo
Couldn‘t get post build model. Module:UpdateService_0804.main Variant: debugOpen logcat panel fo
71 0
|
6月前
|
Java
No tag [else] defined in tag library imported with prefix [c]] with root cause
No tag [else] defined in tag library imported with prefix [c]] with root cause 错误处理
46 0
|
机器学习/深度学习 人工智能
CF788A Functions again
CF788A Functions again
66 0
CF1454 E. Number of Simple Paths (基环树 拓扑排序)
CF1454 E. Number of Simple Paths (基环树 拓扑排序)
92 0
|
Web App开发 测试技术
myAppointment OPA test case issue
myAppointment OPA test case issue
129 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