Question d’entretien chez Luciq

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