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