文章目录
P5708 题目要求
- P5708 题目要求
- P5708 AC代码(Java语言描述)
- P5714 题目要求
- P5714 AC代码(Java语言描述)
- P5720 题目要求
- P5720 AC代码(Java语言描述)
- P5725 题目要求
- P5725 AC代码(Java语言描述)
- P5726 题目要求
- P5726 AC代码(Java语言描述)
- P5732 题目要求
- P5732 AC代码(Java语言描述)
- P5738 题目要求
- P5738 AC代码(Java语言描述)
P5708题目链接
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
double a = scanner.nextDouble(), b = scanner.nextDouble(), c = scanner.nextDouble(), p = (a+b+c)/2;
System.out.printf("%.1f", Math.sqrt(p*(p-a)*(p-b)*(p-c)));
scanner.close();
}
}
P5714 题目要求
P5714题目链接
import java.util.Scanner;
public class Main {
/**
* 有效数字
*/
private static double roundToSignificantFigures(double num, int n) {
if(num == 0) {
return 0;
}
double d = Math.ceil(Math.log10(Math.abs(num)));
int power = n - (int) d;
double magnitude = Math.pow(10, power);
long shifted = Math.round(num*magnitude);
return shifted/magnitude;
}
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
double result = roundToSignificantFigures(scanner.nextDouble()/Math.pow(scanner.nextDouble(), 2), 6);
scanner.close();
if (result
关注
打赏
热门博文
- 【Linux】Ubuntu20.04安装和卸载MySQL8
- 【Linux】Ubuntu 20.04 报错 curl: (23) Failure writing output to destination 的解决方法
- 【Java】JUnit 4.13.2 警告 ‘assertEquals(double, double)‘ is deprecated 的解决方法
- 【JavaScript】处理 @parcel/transformer-js: Browser scripts cannot have imports or exports.
- 【Node.js】Windows环境安装配置NVM和Node.js
- 【Python】处理TypeError: Plain typing.NoReturn is not valid as type argument
- 【Python】Matplotlib可视化50例
- 【C语言】C语言修改MySQL数据库
- 【Java】从默认包导入类和对象报错的解决方法
- 【Java】panel.getGraphics()报错空指针异常的解决方法