当前位置:网站首页>牛客编程题中——需要处理输入较大数的题目
牛客编程题中——需要处理输入较大数的题目
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");
}
}
}
}
边栏推荐
- Reverse resolve dns server
- 解决C#非静态字段、方法或属性“islandnum.Program.getIslandCount(int[][], int, int)”要求对象引用
- HCIP day 3 experiment
- Summer Summary (3)
- MySQL Advanced Statements (1)
- 新产品立大功 伟世通第二季度营收双增
- MySQL high-level --- storage engine, index, lock
- 【暑期每日一题】洛谷 P1551 亲戚
- 两篇不错的php debug教程
- request.getSession(), the story
猜你喜欢

HCIP 第四天

PMP新考纲考试内容介绍

yml字符串读取时转成数字了怎么解决
![[Dataset][VOC] Male and female dataset voc format 6188 sheets](/img/72/d3e46a820796a48b458cd2d0a18f8f.png)
[Dataset][VOC] Male and female dataset voc format 6188 sheets

See the picture to understand | How to choose sales indicators to measure the health of business growth

第06章 索引的数据结构【2.索引及调优篇】【MySQL高级】

MySQL - Multi-table query and case detailed explanation

PMP新考纲通关秘籍,告别抓瞎

optional

Reverse resolve dns server
随机推荐
nacos源码启动找不到istio包
PHP Warning: putenv() has been disabled for security reasons in phar
Reverse resolve dns server
项目开发规范
Facebook社媒营销的5大技巧,迅速提高独立站转化率!
【npm install 报错问题合集】- npm ERR! code ENOTEMPTY npm ERR! syscall rmdir
C# Coding Conventions Handbook
【21天学习挑战赛】顺序查找
实例030:回文数
8/1 思维+扩展欧几里得+树上dp
PHP Warning: putenv() has been disabled for security reasons in phar
【论文精读】Geometric Structure Preserving Warp for Natural Image Stitching
张驰课堂:六西格玛培训工具——箱线图
MySQL Advanced Statements (1)
Day 4 of HCIP
聊天机器人如何提升独立站的营销水平?
Servlet
Py's mlxtend: a detailed guide to the introduction, installation, and usage of the mlxtend library
.NET静态代码织入——肉夹馍(Rougamo) 发布1.1.0
The nacos source code can not find the istio package