当前位置:网站首页>NOI OJ 1.3 14:大象喝水 C语言
NOI OJ 1.3 14:大象喝水 C语言
2022-06-23 10:12:00 【chd44】
描述
一只大象口渴了,要喝20升水才能解渴,但现在只有一个深h厘米,底面半径为r厘米的小圆桶(h和r都是整数)。问大象至少要喝多少桶水才会解渴。
输入
输入有一行:包行两个整数,以一个空格分开,分别表示小圆桶的深h和底面半径r,单位都是厘米。
输出
输出一行,包含一个整数,表示大象至少要喝水的桶数。
这道题主要的难点在于如何判断大象是否正好或者差一点喝饱(解渴)
我们首先通过公式将桶的容量计算出来。
先用20整除它,然后接下来是重点,怎么判断是否正好喝完与否,运用求余的方法可以轻松的得出是否有余数,再运用if语句进行处理。
#include<stdio.h>
int main(){
double a,b,pi=3.14159;
scanf("%lf %lf",&a,&b);
int c=20000/(pi*a*b*b)+1;
printf("%d",c);
return 0;
}注:这里可以投机,因为已知pi后有很多小数,输入的数为整数,所以必然不能进行整除。
可以省略掉求余的过程,直接整除后+1。
边栏推荐
- Spring recruitment interview experience summary (technical post)
- 文献综述怎么写 ,一直没头绪写不出来怎么办?
- Go string comparison
- Fill the pit for repvgg? In fact, it is the repoptimizer open source of repvgg2
- 2021-05-12接口的定义与实现
- 2021-05-12 interface definition and Implementation
- [day 23] given an array of length N, insert element x into the position specified by the array | array insertion operation 4
- Simple understanding of quick sort
- J. Med. Chem. | Release: a new drug design model for deep learning based on target structure
- After the uncommitted transactions in the redo log buffer of MySQL InnoDB are persisted to the redo log, what happens if the transaction rollback occurs? How does the redo log handle this transaction
猜你喜欢

SQL create a new field based on the comparison date

解决audio自动播放无效问题

Fill the pit for repvgg? In fact, it is the repoptimizer open source of repvgg2

利用华为云ECS服务器搭建安防视频监控平台

ICLR 2022 | dynamic convolution tadaconv in video and efficient convolution video understanding model tadaconvnext

数学分析_笔记_第2章:实数与复数

【软件与系统安全】堆溢出

云原生数据库-Amazon RDS

用贪吃蛇小游戏表白(附源码)

Comic | code review is driving me crazy!
随机推荐
解决预览pdf不能下载的问题
Dr. Sun Jian was commemorated at the CVPR conference. The best student thesis was awarded to Tongji Ali. Lifeifei won the huangxutao Memorial Award
Install using snap in opencloudos NET 6
5次登陆失败,限制登录实践
Confessing with Snake games (with source code)
Alimentation des animaux de compagnie basée sur stm32
Data structures and differences between MySQL InnoDB engine and MyISAM
Successful experience of postgraduate entrance examination in materials and Chemical Engineering (metal) of Beijing University of Aeronautics and Astronautics in 2023
High performance computing center RDMA implementation technology
Golang quick start (1)
线程池在项目中使用的心得体会
MySQL optimistic lock and pessimistic lock
Golang 快速上手 (1)
beanstalk 常用方法、说明
Shengshihaotong enables high-quality development with industrial Digitalization
同花顺推荐么?手机开户安全么?
用贪吃蛇小游戏表白(附源码)
How does thymeleaf get the value of the request parameter in the URL?
Nuxt.js spa与ssr的区别
What is JSX in the JS tutorial? Why do we need it?