Luciq interview question

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