日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

CF 287(div 2) B Amr and Pins

發(fā)布時間:2025/5/22 编程问答 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 CF 287(div 2) B Amr and Pins 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

解題思路:一開始自己想的是找出每一次旋轉(zhuǎn)所得到的圓心軌跡,將想要旋轉(zhuǎn)到的點代入該圓心軌跡的方程,如果相等,則跳出循環(huán),如果不相等,則接著進行下一次旋轉(zhuǎn)。后來看了題解,發(fā)現(xiàn),它的旋轉(zhuǎn)可以是任意角度的,所以旋轉(zhuǎn)后的圓心應(yīng)該在一個區(qū)域,而沒有固定的圓心軌跡的方程。

?

如圖所示,設(shè)c0為最初給出的圓,令圓c0繞O1點旋轉(zhuǎn),則對于繞O1點這一點的旋轉(zhuǎn)來說,c1為其旋轉(zhuǎn)后所得到的圓心軌跡,則可以看到,通過1次旋轉(zhuǎn)后,距離最近為0,距離最遠為線段OO2=2r,

對于第二次旋轉(zhuǎn),選取O2為圓心,作圓,再令圓c2繞O3旋轉(zhuǎn),得到圓心的軌跡為c3,離O點最近為OO2=2r,最遠為OO4=4r

所以推出一般結(jié)論,令想要旋轉(zhuǎn)到的點到起始的圓心的距離為d, 那么旋轉(zhuǎn)次數(shù)為d/2r,這里的四舍五入用進1法(不能舍去,所以用ceil函數(shù))

?

B. Amr and Pins

Amr loves Geometry. One day he came up with a very interesting problem.

Amr has a circle of radius?r?and center in point?(x,?y). He wants the circle center to be in new position?(x',?y').

In one step Amr can put a pin to the border of the circle in a certain point, then rotate the circle around that pin by any angle and finally remove the pin.

Help Amr to achieve his goal in minimum number of steps.

Input

Input consists of 5 space-separated integers?r,?x,?y,?x'?y'?(1?≤?r?≤?105,??-?105?≤?x,?y,?x',?y'?≤?105), circle radius, coordinates of original center of the circle and coordinates of destination center of the circle respectively.

Output

Output a single integer — minimum number of steps required to move the center of the circle to the destination point.

Sample test(s) input 2 0 0 0 4 output 1 input 1 1 1 4 4 output 3 input 4 5 6 5 6 output 0 Note

In the first sample test the optimal way is to put a pin at point?(0,?2)?and rotate the circle by?180?degrees counter-clockwise (or clockwise, no matter).

#include<stdio.h> #include<math.h> int main() {double i,r,x0,y0,x1,y1;scanf("%lf %lf %lf %lf %lf",&r,&x0,&y0,&x1,&y1);double dist=sqrt((x1-x0)*(x1-x0)+(y1-y0)*(y1-y0));printf("%.0lf\n",ceil(dist/(2*r))); }

  

轉(zhuǎn)載于:https://www.cnblogs.com/wuyuewoniu/p/4252188.html

總結(jié)

以上是生活随笔為你收集整理的CF 287(div 2) B Amr and Pins的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。