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 925 (Div. 3) 1931D. Divisible Pairs Solution

        Problem Link  :   https://codeforces.com/contest/1931/problem/D S olution in C++: /// Author : AH_Tonmoy #include < bits / stdc ++. ...

    Powered by Blogger.