+ 1
3rd Jan 2020, 10:55 AM
Deepak Singh
Deepak Singh - avatar
2 Antworten
+ 3
Where do you need help? First task: 8 2 1 9 5 -> 6 4 7 2 3 8 -> 7 -> 6 //2 2 -> 3 -> 4 //2 1 -> 0 -> 9 -> 8 -> 7 //4 9 -> 0 -> 1 -> 2 //3 5 -> 4 -> 3 //2 Output: 13 You only need to decide which distance is smaller. 8 -> 7 -> 6 vs 8 -> 9 -> 0 -> 1 ... -> 6 Second task: n = 6, m = 2, a = 1, b = 2 n rides / m 6/2 = 3 -> you need 3 m ride tickets 3 m ride tickets * b = 6 You can also buy 6 tickets for 1 6 * 1 = 6 n = 5, m = 2, a = 2, b = 3 5/m = 2 Buy 2 m ride tickets * b = 6 Buy 1 ride * a = 2 -> cost: 8 Buying only normal tickets would cost 5 * 2 = 10 Output: 8
3rd Jan 2020, 12:44 PM
Denise Roßberg
Denise Roßberg - avatar
+ 1
Thanks bro
3rd Jan 2020, 1:10 PM
Deepak Singh
Deepak Singh - avatar