Codeforces 1521A. Nastia and Nearly Good Numbers
Explain:
case 1:if b==1 .this time answer not exist because good is not possible .
case 2 : if b>1 ans is A+A.B=A.(1+B)
Solution in C++:
///La ilaha illellahu muhammadur rasulullah
///******Bismillahir-Rahmanir-Rahim******///
///AH Tonmoy
///Department of CSE,23rd batch
///Islamic University,Bangladesh
- #include <bits/stdc++.h>
- using namespace std;
- int main()
- {
- long long int t,a,b,x,y,z;
- cin>>t;
- while(t--)
- {
- cin>>a>>b;
- x=a;
- y=a*b;
- z=x+y;
- if(b!=1)
- {
- cout<<"YES"<<endl;
- cout<<x<<" "<<y<<" "<<z<<endl;
- }
- else
- cout<<"NO"<<endl;
- }
- }
No comments