Codeforces Round #365 (Div. 2) E. Mishka and Divisors

http://codeforces.com/contest/703/problem/E 問題自体は典型だけど TL 1000ms + オーバーフロー + K=1 のコーナーケースで苦しめられた。