#include using namespace std; int main() { int L,R,C,A; A = 1000; cin >> L >> R >> C; int l = L/1000*1000; int r = R/1000*1000; int c = C/1000*1000; for (int i = l; i < r; i++){ if (A > ((i * c - 1) / 1000 + 1) * 1000 - i * c) { A = ((i * c - 1) / 1000 + 1) * 1000 - i * c; } cout << ((i * c-1) / 1000 + 1) << " " << A << endl; } cout << A << endl; return 0; }