Luciq Interview Question

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