当前位置:网站首页>Yyds dry goods inventory # solve the real problem of famous enterprises: move the round table
Yyds dry goods inventory # solve the real problem of famous enterprises: move the round table
2022-07-05 13:00:00 【51CTO】
1. sketch :
describe
Now there is a picture with a radius of r Round table , Its center is in (x,y), Now he wants to move the center of the round table to (x1,y1). Move one step at a time , Must fix a point on the edge of the round table, and then rotate the round table around this point . Ask how many steps you need to move at least .
Input description :
Five integers in a row r,x,y,x1,y1(1≤r≤100000,-100000≤x,y,x1,y1≤100000)
Output description :
Output an integer , Answer
Example 1
Input :
Output :
2. Code implementation :
import java.util.Scanner;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n =0;
double distance =0;
while(sc.hasNext()){
// Use long Prevent large number multiplication overflow int Range
int r = sc.nextInt();
long x = sc.nextInt();
long y = sc.nextInt();
long x1 = sc.nextInt();
long y1 = sc.nextInt();
double a=(x1-x)*(x1-x)+(y1-y)*(y1-y);
distance=Math.sqrt(a);
n = (int)distance/(2*r);
// If it can't be divided in the end , Need to rotate again
if((n*2*r)<distance){
n++;
}
System.out.println(n);
}
}
}
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
- 18.
- 19.
- 20.
- 21.
- 22.
- 23.
- 24.
- 25.
- 26.
边栏推荐
- 10 minute fitness method reading notes (1/5)
- 谈谈我写作生涯的画图技巧
- 《2022年中國銀行業RPA供應商實力矩陣分析》研究報告正式啟動
- 跨平台(32bit和64bit)的 printf 格式符 %lld 输出64位的解决方式
- A possible investment strategy and a possible fuzzy fast stock valuation method
- HiEngine:可媲美本地的云原生内存数据库引擎
- Rasa Chat Robot Tutorial (translation) (1)
- 开发者,云原生数据库是未来吗?
- Talk about my drawing skills in my writing career
- #yyds干货盘点#js截取文件后缀名
猜你喜欢
![[cloud native] use of Nacos taskmanager task management](/img/ad/24bdd4572ef9990238913cb7cd16f8.png)
[cloud native] use of Nacos taskmanager task management

leetcode:221. 最大正方形【dp状态转移的精髓】

Distance measuring sensor chip 4530a used in home intelligent lighting

石臻臻的2021总结和2022展望 | 文末彩蛋

深度长文探讨Join运算的简化和提速

【云原生】Nacos中的事件发布与订阅--观察者模式

Transactions from January 6 to October 2022

VoneDAO破解组织发展效能难题

Pinduoduo flag insertion remarks API

《2022年中國銀行業RPA供應商實力矩陣分析》研究報告正式啟動
随机推荐
Developers, is cloud native database the future?
Insmod prompt invalid module format
《2022年中国银行业RPA供应商实力矩阵分析》研究报告正式启动
A small talk caused by the increase of sweeping
SAP UI5 ObjectPageLayout 控件使用方法分享
HiEngine:可媲美本地的云原生内存数据库引擎
About LDA model
Annotation problem and hidden Markov model
滴滴开源DELTA:AI开发者可轻松训练自然语言模型
谈谈我写作生涯的画图技巧
Introduction to sap ui5 dynamicpage control
【云原生】Nacos中的事件发布与订阅--观察者模式
LeetCode20.有效的括号
Leetcode20. Valid parentheses
非技术部门,如何参与 DevOps?
Taobao short videos are automatically released in batches without manual RPA open source
Taobao order amount check error, avoid capital loss API
10 minute fitness method reading notes (2/5)
MySQL giant pit: update updates should be judged with caution by affecting the number of rows!!!
Le rapport de recherche sur l'analyse matricielle de la Force des fournisseurs de RPA dans le secteur bancaire chinois en 2022 a été officiellement lancé.