Codeforces 507B. AMR and Pins Problem solving report

Source: Internet
Author: User



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


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.