From c24ac8c407d3345bd44579e1109a6625dca64c43 Mon Sep 17 00:00:00 2001 From: ShazidMahsrafi Date: Tue, 25 Jul 2023 01:26:01 +0600 Subject: [PATCH] initial commit --- 189A Cut Ribbon/189A.cpp | 93 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 189A Cut Ribbon/189A.cpp diff --git a/189A Cut Ribbon/189A.cpp b/189A Cut Ribbon/189A.cpp new file mode 100644 index 0000000..eba008b --- /dev/null +++ b/189A Cut Ribbon/189A.cpp @@ -0,0 +1,93 @@ +#include +using namespace std; +using ll = long long; + + +void solve() +{ + int n, a, b, c; + cin>>n; + vectorv; + for(int i=0; i<3; ++i) + { + int x; + cin>>x; + v.push_back(x); + } + sort(v.begin(),v.end()); + vectorcts; + int temp,ct,tct; + if(n%v[0]==0) + { + cts.push_back(n/v[0]); + } + else + { + temp=n; + ct=0; + while(temp>0) + { + temp=temp-v[1]; + ct++; + if(temp%v[0]==0 && temp>=v[0]) + { + ct=ct+temp/v[0]; + temp=temp%v[0]; + break; + } + } + if(temp==0) + cts.push_back(ct); + + temp=n; + ct=0; + while(temp>0) + { + temp=temp-v[2]; + ct++; + if(temp%v[0]==0 && temp>=v[0]) + { + ct=ct+temp/v[0]; + temp=temp%v[0]; + break; + } + } + if(temp==0) + cts.push_back(ct); + + ct=0; + while(n>0) + { + n=n-v[2]; + ct++; + temp=n; + tct=ct; + while(temp>0) + { + temp=temp-v[1]; + tct++; + if(temp%v[0]==0 && temp>=v[0]) + { + tct=tct+temp/v[0]; + temp=temp%v[0]; + break; + } + } + if(temp==0) + cts.push_back(tct); + } + } + int ans=*max_element(cts.begin(),cts.end()); + cout<> TC; + //cin.ignore(); + while (TC--) solve(); +} \ No newline at end of file