Skip to content

Commit 4d23738

Browse files
Create AvtoBus Explanation.txt
1 parent febabbe commit 4d23738

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
When we want to maximize the number of buses, we will try to maximise the number of 4's.
2+
While trying to minimize, we will try to maximize the number of 6's.
3+
4+
There is no answer possible if N = 1, 3 (mod 4).
5+
6+
There are only 2 cases where an answer exists.
7+
N = 0, 2 (mod 4)
8+
9+
-----
10+
11+
void solve()
12+
{
13+
long long no_of_wheels;
14+
cin >> no_of_wheels;
15+
16+
long long minimum, maximum;
17+
switch(no_of_wheels%4)
18+
{
19+
case 0: maximum = no_of_wheels/4;
20+
minimum = 2*(no_of_wheels/12) + (no_of_wheels%12 == 6 ? (no_of_wheels%12)/6 : (no_of_wheels%12)/4);
21+
break;
22+
23+
case 2: if(no_of_wheels == 2)
24+
{
25+
cout << "-1\n";
26+
return;
27+
}
28+
maximum = 1 + (no_of_wheels - 6)/4;
29+
no_of_wheels -= 6;
30+
minimum = 1 + 2*(no_of_wheels/12) + (no_of_wheels%12 == 6 ? (no_of_wheels%12)/6 : (no_of_wheels%12)/4);
31+
break;
32+
33+
default: cout << "-1\n";
34+
return;
35+
}
36+
37+
cout << minimum << " " << maximum << "\n";
38+
}

0 commit comments

Comments
 (0)