#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) << " " << ((i * C-1) / 1000 + 1) << " " << A << endl; } cout << A << endl; return 0; }