#include //#include //#include int main(void){ //srand(time(NULL)); int L,R,C,x; int oturi,min; //int second; scanf("%lld %lld %lld",&L,&R,&C); min = 999; //while(second < 2){ //second = time(NULL); //L = rand(); //R = rand(); //C = rand(); for(x = L;x <= R;x++){ oturi = ((1000 - ((x*C) % 1000)) % 1000); if(oturi < min){ min = oturi; } } //printf("L:%d R:%d C:%d\n",L,R,C); printf("%d\n",min); //second = time(NULL) - second; //printf("経過時間:%d\n",second); //printf("\n"); //} return 0; }