문제 링크:https://nypc.github.io/2018/2018_online_3.html
코드
...더보기
#include <stdio.h>
#include <Windows.h>
int main(void) {
int HP = 0, MP = 0;
int HPCount = 0, MPCount = 0;
int W = 0;
int i = 0;
scanf("%d %d", &HP, &MP);
scanf("%d", &W);
HPCount = W % HP == 0 ? W / HP : -1;
if (HPCount == -1) {
while (1) {
int temp = HP*i;
if ((W - temp) % MP == 0) {
HPCount = i;
MPCount = (W - temp) / MP;
break;
}
i++;
}
}
printf("%d %d", HPCount, MPCount);
system("Pause");
}
댓글