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