Title Link: Http://codeforces.com/problemset/problem/507/B
Title: Give the radius of the circle, as well as the coordinates of the center and the final center to reach the coordinate position. Ask the minimum number of steps. Mobile See. (Through the circle on the edge of the fixed rotation point, and then rotate any position, the center will move, this or directly to see the picture bar)
The idea of solving the problem is that between two points, the shortest distance ~ ~ ~ ~ to get the minimum number of steps, we need to ensure that the center of the link in the movement, each rotation angle is 180 degrees, and each step of the distance is 2r, until two circle intersection, to note that the last step of the rotation angle may be less than 180 degrees. The last is to pay attention to the accuracy, with the ceiling function ceil () ~ ~ ~ ~ more detailed ideas for solving the problem, please refer to the official solution.
http://codeforces.com/blog/entry/15975
1 #include <iostream>
2 #include <cstdio>
3 #include <cstring>
4 #include <cmath>
5 using namespace std;
6
7 typedef __int64 ll;
8
9 int main()
10 {
11 ll r, x, y, x1, y1;
12 while (cin >> r >> x >> y >> x1 >> y1) {
13 ll difx = (x-x1)*(x-x1);
14 ll dify = (y-y1)*(y-y1);
15 ll ans = ceil(sqrt(difx + dify) / (2*r));
16 printf("%I64d\n", ans);
17 }
18 return 0;
19 }
Codeforces 507B. AMR and Pins Problem solving report