forked from Tushargupta9800/CSES-solutions
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCut_Ribbon.cpp
More file actions
34 lines (32 loc) · 727 Bytes
/
Cut_Ribbon.cpp
File metadata and controls
34 lines (32 loc) · 727 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n, a, b, c;
cin >> n >> a >> b >> c;
int ans = INT_MIN;
for (int i = 0; i <= 4000; i++)
{
if (a * i > n)
{
break;
}
for (int j = 0; j <= 4000; j++)
{
if ((a * i + b * j) > n)
{
break;
}
// if (i == 0 and j == 1)
// {
// cout << (n - (a * i + b * j)) / c << endl;
// }
if ((n - (a * i + b * j)) % c == 0)
{
int num = (n - (a * i + b * j)) / c;
ans = max(ans, (i + j + num));
}
}
}
cout << ans << endl;
}