当前位置:网站首页>牛客编程题中——需要处理输入较大数的题目
牛客编程题中——需要处理输入较大数的题目
2022-08-02 06:35:00 【小突击花呀】
1. 题目: 小喵们很喜欢把自己装进容器里的(例如碗),但是要是碗的周长比喵的身长还短,它们就进不去了。
现在告诉你它们的身长,和碗的半径,请判断一下能否到碗里去。
输入描述:
输入有多组数据。
每组数据包含两个整数n (1≤n≤2^128) 和r (1≤r≤2^128),分别代表喵的身长和碗的半径。
圆周率使用3.14。
输出描述:
对应每一组数据,如果喵能装进碗里就输出“Yes”;否则输出“No”。
代码:
import java.util.*;
import java.math.*;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
while(sc.hasNext()){
BigDecimal n = sc.nextBigDecimal();
BigDecimal r = sc.nextBigDecimal();
BigDecimal len = new BigDecimal("6.28").multiply(r);
System.out.println(n.compareTo(len) == 1 ? "No" :"Yes");
}
}
}
2. 三角形
题目:给定三条边,请你判断一下能不能组成一个三角形。
输入描述: 输入包含多组数据,每组数据包含三个正整数a、b、c(1≤a, b, c≤10^100)。
输出描述: 对应每一组数据,如果它们能组成一个三角形,则输出“Yes”;否则,输出“No”。
代码:
import java.util.*;
import java.math.*;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
while(sc.hasNext()){
BigDecimal a = sc.nextBigDecimal();
BigDecimal b = sc.nextBigDecimal();
BigDecimal c = sc.nextBigDecimal();
if((a.add(b).compareTo(c)>0) && (a.add(c).compareTo(b)>0) && (b.add(c).compareTo(a)>0)){
System.out.println("Yes");
}else{
System.out.println("No");
}
}
}
}
边栏推荐
猜你喜欢

How the Internet of Things is changing the efficiency of city operations

“蔚来杯“2022牛客暑期多校训练营5,签到题KBGHFCD

ASP.NET Core Web API 幂等性

yml字符串读取时转成数字了怎么解决

8/1 思维+扩展欧几里得+树上dp

文件上传漏洞(二)

_2_顺序表
![(Part of it is not understood, and the notes are not completed) [Graph Theory] Difference Constraints](/img/e0/385579fc8657db8b175318bd739908.gif)
(Part of it is not understood, and the notes are not completed) [Graph Theory] Difference Constraints

(笔记整理未完成)【图论】图的遍历
![[数据集][VOC]男女数据集voc格式6188张](/img/72/d3e46a820796a48b458cd2d0a18f8f.png)
[数据集][VOC]男女数据集voc格式6188张
随机推荐
结构体大小计算--结构体内存对齐
有人开源全凭“为爱发电”,有人却用开源“搞到了钱”
(部分不懂,笔记整理未完成)【图论】差分约束
数据库概论之MySQL表的增删改查2
武汉高性能计算大会2022举办,高性能计算生态发展再添新动力
返回文件名问题
yml字符串读取时转成数字了怎么解决
Leetcode周赛304
速看!PMP新考纲、PMBOK第七版解读
love
odoo field 设置匿名函数domain
Specified URL is not reachable,caused by :‘Read timed out
【红队】ATT&CK - 创建或修改系统进程实现持久化(更新ing)
August 2022 plan, focusing on ue4 video tutorials
DNS resolution process
typescript ‘props‘ is declared but its value is never read 解决办法
File upload vulnerability (2)
Swagger的简单介绍,集成,以及如何在生产环境中关闭swagger,在测试和开发环境中自动打开
.NET Static Code Weaving - Rougamo Release 1.1.0
awk语法-01-基础语法(命令、选项、内部变量)