Codeforces 189A. Cut Ribbon Solution

  Solution in C++:

 ///La ilaha illellahu muhammadur rasulullah

///******Bismillahir-Rahmanir-Rahim******///

///Abul Hasnat  Tonmoy

///Department of CSE,23rd batch

    ///Islamic University,Bangladesh

    1. #include <bits/stdc++.h>
    2. using namespace std;
    3. int main()
    4. {
    5. int t,n,a,b,c,ans=0,tm;
    6. cin>>n>>a>>b>>c;
    7. int x,y,z,zc;
    8. for(int x=0; x<=4000; x++)
    9. {
    10. for(int y=0; y<=4000; y++)
    11. {
    12. zc=n-(a*x+b*y);
    13. if(zc<0)
    14. break;
    15.  
    16. double z=(zc/(double)c);
    17. if(z==(int)z)
    18. ans=max(ans,(int)z+x+y);
    19. }
    20. }
    21. cout<<ans<<endl;
    22. }

    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 ...

    Powered by Blogger.