当前位置:网站首页>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.
边栏推荐
- RHCAS6
- Wechat enterprise payment to change access, open quickly
- Insmod prompt invalid module format
- Shi Zhenzhen's 2021 summary and 2022 outlook | colorful eggs at the end of the article
- RHCSA3
- Install rhel8.2 virtual machine
- RHCSA1
- SAP self-development records user login logs and other information
- Four common problems of e-commerce sellers' refund and cash return, with solutions
- Alipay transfer system background or API interface to avoid pitfalls
猜你喜欢
Install rhel8.2 virtual machine
SAP SEGW 事物码里的 ABAP 类型和 EDM 类型映射的一个具体例子
Introduction to the principle of DNS
SAP SEGW 事物码里的导航属性(Navigation Property) 和 EntitySet 使用方法
Taobao short video, why the worse the effect
2021-12-22 transaction record
HiEngine:可媲美本地的云原生内存数据库引擎
【云原生】Nacos-TaskManager 任务管理的使用
What if wechat is mistakenly sealed? Explain the underlying logic of wechat seal in detail
Pinduoduo flag insertion remarks API
随机推荐
Taobao order amount check error, avoid capital loss API
滴滴开源DELTA:AI开发者可轻松训练自然语言模型
实战模拟│JWT 登录认证
How do e-commerce sellers refund in batches?
《信息系统项目管理师》备考笔记---信息化知识
超高效!Swagger-Yapi的秘密
你的下一台电脑何必是电脑,探索不一样的远程操作
Developers, is cloud native database the future?
Shi Zhenzhen's 2021 summary and 2022 outlook | colorful eggs at the end of the article
Alipay transfer system background or API interface to avoid pitfalls
Run, open circuit
Kotlin variable
Distance measuring sensor chip 4530a used in home intelligent lighting
[cloud native] event publishing and subscription in Nacos -- observer mode
Yyds dry inventory JS intercept file suffix
#yyds干货盘点#js截取文件后缀名
RHCSA3
Four common problems of e-commerce sellers' refund and cash return, with solutions
mysql拆分字符串做条件查询
#yyds干货盘点# 解决名企真题:搬圆桌