-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy path1214A.cpp
More file actions
36 lines (33 loc) · 692 Bytes
/
1214A.cpp
File metadata and controls
36 lines (33 loc) · 692 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
35
36
#include <bits/stdc++.h>
using namespace std;
int main()
{
long long n,d,e;
cin >> n >> d >> e;
long long x1, x2, y1, y2, ans1 = INT_MAX, ans2 = INT_MAX;
x1 = n/(5*e);
while(x1 != -1) {
y1 = (n-(5*e*x1))/d;
ans1 = n-(5*e*x1)-(y1*d);
ans2 = min(ans1,ans2);
if(ans2 == 0) {
cout << ans2;
return 0;
}
x1--;
}
ans1 = ans2;
y2 = n / d;
while(y2 != -1) {
x2 = (n-(y2*d))/(5*e);
ans2 = n-(5*e*x2)-(y2*d);
ans1 = min(ans1,ans2);
if(ans1 == 0) {
cout << ans1;
return 0;
}
y2--;
}
cout << ans1;
return 0;
}