当前位置:网站首页>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.
边栏推荐
- Taobao, pinduoduo, jd.com, Doudian order & Flag insertion remarks API solution
- 开发者,云原生数据库是未来吗?
- SAP SEGW 事物码里的 Association 建模方式
- Taobao product details API | get baby SKU, main map, evaluation and other API interfaces
- SAP ui5 objectpagelayout control usage sharing
- RHCSA3
- 石臻臻的2021总结和2022展望 | 文末彩蛋
- From the perspective of technology and risk control, it is analyzed that wechat Alipay restricts the remote collection of personal collection code
- 由扫地增而引起的小叙
- What is the difference between Bi software in the domestic market
猜你喜欢
Introduction to the principle of DNS
Alipay transfer system background or API interface to avoid pitfalls
OpenHarmony应用开发之Navigation组件详解
HiEngine:可媲美本地的云原生内存数据库引擎
关于 SAP UI5 floating footer 显示与否的单步调试以及使用 SAP UI5 的收益
RHCAS6
Laravel文档阅读笔记-mews/captcha的使用(验证码功能)
Transactions from December 29, 2021 to January 4, 2022
Hiengine: comparable to the local cloud native memory database engine
How can non-technical departments participate in Devops?
随机推荐
Taobao product details API | get baby SKU, main map, evaluation and other API interfaces
Transactions from December 27 to 28, 2021
NFT: how to make money with unique assets?
[Nacos cloud native] the first step of reading the source code is to start Nacos locally
From the perspective of technology and risk control, it is analyzed that wechat Alipay restricts the remote collection of personal collection code
使用 jMeter 对 SAP Spartacus 进行并发性能测试
Wechat enterprise payment to change access, open quickly
NLP engineer learning summary and index
SAP UI5 DynamicPage 控件介绍
Notes for preparation of information system project manager --- information knowledge
Simply take stock reading notes (3/8)
Taobao order interface | order flag remarks, may be the most stable and easy-to-use interface
Taobao short video, why the worse the effect
Hiengine: comparable to the local cloud native memory database engine
单独编译内核模块
10 minute fitness method reading notes (5/5)
DNS的原理介绍
stirring! 2022 open atom global open source summit registration is hot!
我在滴滴做开源
超高效!Swagger-Yapi的秘密