当前位置:网站首页>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.
边栏推荐
猜你喜欢
The Research Report "2022 RPA supplier strength matrix analysis of China's banking industry" was officially launched
[Nacos cloud native] the first step of reading the source code is to start Nacos locally
CF:A. The Third Three Number Problem【关于我是位运算垃圾这个事情】
10 minute fitness method reading notes (5/5)
Super efficient! The secret of swagger Yapi
SAP UI5 FlexibleColumnLayout 控件介绍
RHCSA5
Simply take stock reading notes (2/8)
VoneDAO破解组织发展效能难题
10 minute fitness method reading notes (3/5)
随机推荐
滴滴开源DELTA:AI开发者可轻松训练自然语言模型
I met Tencent in the morning and took out 38K, which showed me the basic smallpox
潘多拉 IOT 开发板学习(HAL 库)—— 实验7 窗口看门狗实验(学习笔记)
Alipay transfer system background or API interface to avoid pitfalls
SAP SEGW 事物码里的 ABAP 类型和 EDM 类型映射的一个具体例子
Taobao, pinduoduo, jd.com, Doudian order & Flag insertion remarks API solution
stm32和电机开发(从架构图到文档编写)
The solution of outputting 64 bits from printf format%lld of cross platform (32bit and 64bit)
A deep long article on the simplification and acceleration of join operation
Setting up sqli lab environment
[Nacos cloud native] the first step of reading the source code is to start Nacos locally
Why is your next computer a computer? Explore different remote operations
以VMware创新之道,重塑多云产品力
How to connect the API interface of Taobao open platform (super detailed)
946. 验证栈序列
Annotation problem and hidden Markov model
Natural language processing series (I) introduction overview
Halcon template matching actual code (I)
10 minute fitness method reading notes (2/5)
实战模拟│JWT 登录认证