当前位置:网站首页>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.
边栏推荐
- RHCSA4
- 开发者,云原生数据库是未来吗?
- The solution of outputting 64 bits from printf format%lld of cross platform (32bit and 64bit)
- PyCharm安装第三方库图解
- RHCSA2
- SAP SEGW 事物码里的导航属性(Navigation Property) 和 EntitySet 使用方法
- MySQL splits strings for conditional queries
- Yyds dry inventory JS intercept file suffix
- A deep long article on the simplification and acceleration of join operation
- Taobao short videos are automatically released in batches without manual RPA open source
猜你喜欢

10 minute fitness method reading notes (5/5)

Hiengine: comparable to the local cloud native memory database engine

HiEngine:可媲美本地的云原生内存数据库引擎

The Research Report "2022 RPA supplier strength matrix analysis of China's banking industry" was officially launched

Talk about my drawing skills in my writing career

Shi Zhenzhen's 2021 summary and 2022 outlook | colorful eggs at the end of the article

stirring! 2022 open atom global open source summit registration is hot!
![[Nacos cloud native] the first step of reading the source code is to start Nacos locally](/img/f8/d9b848593cf7380a6c99ee0a8158f8.png)
[Nacos cloud native] the first step of reading the source code is to start Nacos locally

Actual combat simulation │ JWT login authentication

深度长文探讨Join运算的简化和提速
随机推荐
由扫地增而引起的小叙
2021.12.16-2021.12.20 empty four hand transaction records
Reshape the power of multi cloud products with VMware innovation
MySQL giant pit: update updates should be judged with caution by affecting the number of rows!!!
谈谈我写作生涯的画图技巧
A possible investment strategy and a possible fuzzy fast stock valuation method
实战模拟│JWT 登录认证
##无监控,不运维,以下是监控里常用的脚本监控
滴滴开源DELTA:AI开发者可轻松训练自然语言模型
实现 1~number 之间,所有数字的加和
HiEngine:可媲美本地的云原生内存数据库引擎
NLP engineer learning summary and index
Rasa Chat Robot Tutorial (translation) (1)
Introduction aux contrôles de la page dynamique SAP ui5
Notes for preparation of information system project manager --- information knowledge
【Nacos云原生】阅读源码第一步,本地启动Nacos
Talk about my drawing skills in my writing career
From the perspective of technology and risk control, it is analyzed that wechat Alipay restricts the remote collection of personal collection code
Simply take stock reading notes (1/8)
insmod 提示 Invalid module format