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

    1. #include <bits/stdc++.h>
    2. using namespace std;
    3. int main()
    4. {
    5. long long int t,a,b,x,y,z;
    6. cin>>t;
    7. while(t--)
    8. {
    9. cin>>a>>b;
    10. x=a;
    11. y=a*b;
    12. z=x+y;
    13. if(b!=1)
    14. {
    15. cout<<"YES"<<endl;
    16. cout<<x<<" "<<y<<" "<<z<<endl;
    17. }
    18. else
    19. cout<<"NO"<<endl;
    20. }
    21. }

    No comments

    Most View Post

    Recent post

    Codeforces Round 971 (Div. 4) 2009C. The Legend of Freya the Frog Solution

      Problem Link    https://codeforces.com/contest/2009/problem/C S olution in C++: /// Author : AH_Tonmoy #include < bits / stdc ++. h &g...

    Powered by Blogger.