implicit none integer(8) A,X,Y,L read(*,*) X read(*,*) Y read(*,*) L if (mod(X,L)==0) then if (mod(Y,L)==0) then A=abs(X/L)+abs(Y/L) else A=abs(X/L)+abs(Y/L)+1 end if else if (mod(Y,L)==0) then A=abs(X/L)+1+abs(Y/L) else A=abs(X/L)+abs(Y/L)+2 end if end if if (Y>=0) then if (X==0) then A=A+0 else A=A+1 end if else A=A+2 end if write(*,*) A end