Frage im Vorstellungsgespräch bei Luciq

2 problem solving questions. Codeforces style. Required basic math and binary search.