当前位置:网站首页>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.
边栏推荐
- Insmod prompt invalid module format
- RHCSA7
- 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é.
- Simply take stock reading notes (3/8)
- RHCSA4
- Laravel document reading notes -mews/captcha use (verification code function)
- 实现 1~number 之间,所有数字的加和
- SAP self-development records user login logs and other information
- Lepton 无损压缩原理及性能分析
- ABAP editor in SAP segw transaction code
猜你喜欢

Introduction to sap ui5 flexiblecolumnlayout control

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

Laravel文档阅读笔记-mews/captcha的使用(验证码功能)

实战模拟│JWT 登录认证

PyCharm安装第三方库图解

SAP UI5 视图里的 OverflowToolbar 控件

国内市场上的BI软件,到底有啥区别

Oppo Xiaobu launched Obert, a large pre training model, and promoted to the top of kgclue

SAP ui5 objectpagelayout control usage sharing

Developers, is cloud native database the future?
随机推荐
Insmod prompt invalid module format
Reshape the power of multi cloud products with VMware innovation
RHCSA2
From the perspective of technology and risk control, it is analyzed that wechat Alipay restricts the remote collection of personal collection code
Super efficient! The secret of swagger Yapi
The solution of outputting 64 bits from printf format%lld of cross platform (32bit and 64bit)
Laravel文档阅读笔记-mews/captcha的使用(验证码功能)
Difference between JUnit theories and parameterized tests
DNS的原理介绍
逆波兰表达式
Annotation problem and hidden Markov model
Leetcode20. Valid parentheses
Comprehensive upgrade of Taobao short video photosynthetic platform
RHCSA5
Simply take stock reading notes (1/8)
关于 SAP UI5 floating footer 显示与否的单步调试以及使用 SAP UI5 的收益
NLP engineer learning summary and index
函数传递参数小案例
[Nacos cloud native] the first step of reading the source code is to start Nacos locally
超高效!Swagger-Yapi的秘密