题目描述
现在有一张半径为r的圆桌,其中心位于(x,y),现在他想把圆桌的中心移到(x1,y1)。每次移动一步,都必须在圆桌边缘固定一个点然后将圆桌绕这个点旋转。问最少需要移动几步。
输入描述:
一行五个整数r,x,y,x1,y1(1≤r≤100000,-100000≤x,y,x1,y1≤100000)
输出描述:
输出一个整数,表示答案
示例1
输入
2 0 0 0 4
输出
1
#include <iostream>
#include <iomanip>
#include<string>
#include<algorithm>
#include <math.h>
using namespace std;
int main(){
float r,x,y,x1,y1;
while(cin >> r >> x >> y >> x1 >> y1){
float d2 = sqrt((x1 -x)*(x1 -x) + (y1 - y)*(y1 - y));
int cnt = d2/2/r;
int result = ceil(cnt);
cout << result <<endl;
}
return 0;
}
注意输入参数设定为float