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

    RESTful APIs with CRUD Operations in Laravel 12| (2025)

      RESTful APIs serve as the foundation of modern web development. They follow a set of rules called Representational State Transfer (REST) t...

    Powered by Blogger.