codility

Codility - FrogJmp

로빈 아빠 2020. 3. 10. 01:11

integer 3개가 주어지는데, x는 시작지점, y는 목표지점, d는 이동 가능 거리를 의미함.

개구리는 면 번만에 목표 지점에 도달할 수 있는지에 대한 문제

 

소스 코드

int solution( int x, int y, int d )
{
  int nFarfrom = y - x;
  int nValue = nFarfrom / d;
  int nRemain = nFarfrom % d;
 
  if( nRemain != 0 )
     return nValue + 1;

  return nValue;
}