当前位置:网站首页>P2394 yyy loves Chemistry I
P2394 yyy loves Chemistry I
2022-06-28 09:06:00 【暴揍键盘的程序猿】
P2394 yyy loves Chemistry I
# yyy loves Chemistry I
## 题目背景
因为会吃回车,所以放到题目描述里了喵~
## 题目描述
[故事背景]
从前,有个人叫yyy,他特别喜欢化学,尤其是一些很危(zuo)险(si)的实验.
[题目背景]
这一天,他开始研究起了一个神奇又有趣的方程式
2Na + 2H2O ==== 2NaOH + H2↑
[问题描述]
现在yyy将一块质量为xg的钠投入很多的水中,然后开始收集氢气.
最终,我们知道,后来,这块钠在水中游动着消失了.而yyy很厉害,把氢气全收集起来了.
**已知每投入了23克的钠,就会生成1克的氢气.**
那么现在yyy收集了多少克氢气呢?
## 输入格式
一行,一个实数x,代表yyy将多少克钠投入了水中
输入文件行末一定**不会**有一只回车啦~
## 输出格式
一行,一个实数(四舍五入精确到8位小数),代表生成了多少克氢气
## 样例 #1
### 样例输入 #1
```
0.23
```
### 样例输出 #1
```
0.01000000
```
## 提示
[数据规模]
对于100%的数据,0<x<=1
[提示]
你想知道x有几位小数吗?才不给你呢>\_<
我只知道空间限制是4M,时间限制是0.1s,而且如果你把数字全读下来的话可能就MLE咯~
kkksc:没有数据范围怎么行!输入文件不超过5M!
出题人:怎么能这样!差评!我不好挖坑了!
【翻译】
输入一个
死鬼特别长的实数x,输出x/23保留8位小数的值。
【AC代码】
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<string>
#include<vector>
using namespace std;
long double x;
signed main()
{
scanf("%15Lf",&x);
cout<<fixed<<setprecision(8)<<x/23;
return 0;
}

【高级做法】
#include <iostream>
#include <cstdio>
using std::scanf;
using std::printf;
int x;
char c;
int len(int a) //返回数的长度
{
if (a==0)
return 1;
int ans=0;
while (a)
{
++ans;
a/=10;
}
return ans;
}
int main()
{
if ((c=getchar())=='1') //特判
{
long double y=1;
printf("%.8Lf", y/23);
return 0;
}
getchar();
bool flg=false;
for (int i=1; i<=9; ++i)
{
if (!flg)
c=getchar();
if (c>'9'||c<'0')
x*=10, flg=true;
else
x=(x<<3)+(x<<1)+c-'0';
}
x=(x/23+5)/10; //四舍五入
putchar('0');
putchar('.');
int length=len(x);
for (int i=1; i<=8-len(x); ++i) //补上前导零
putchar('0');
printf("%d\n", x);
return 0;
}
选自樱初音斗橡皮
大佬蒟蒻奆佬(纠结地打出了奆佬)的TJ。袁隆平:我这辈子最大的错事就是让
樱初音斗橡皮中国人吃撑了没事干——MC方块人
边栏推荐
- What are the advantages of a differential probe over a conventional probe
- DEJA_ Vu3d - 052 of cesium feature set - Simulation of satellite orbit (high altitude) effect
- Calcul des frais d'achat et de vente d'actions
- 我想网上注册股票开户,如何操作?在线开户安全么?
- 用Pytorch搭建第一個神經網絡且進行優化
- 104. maximum depth of binary tree
- Rman Backup Report Ora - 19809 Ora - 19804
- SQL 优化经历:从 30248秒到 0.001秒的经历
- Loggerfactory uses log4j Parameter introduction of properties
- Implementation of single sign on
猜你喜欢

如何抑制SiC MOSFET Crosstalk(串擾)?

Decision table method for basic content learning of software testing (2)

APICloud携手三六零天御,助力企业守好App安全“第一关”

Application of current limiting protector in preventing electrical fire in shopping malls

Calculation of stock purchase and sale expenses

Postman interface test
![[.Net6] GRP server and client development cases, as well as the access efficiency duel between the minimum API service, GRP service and traditional webapi service](/img/19/296f124becb87461accf8b73b0a8bc.png)
[.Net6] GRP server and client development cases, as well as the access efficiency duel between the minimum API service, GRP service and traditional webapi service

Test cases for learning the basic content of software testing (II)

Expérience d'optimisation SQL: de 30248 secondes à 0001 secondes

"Jianzhi offer" -- Interview Question 4: finding two-dimensional arrays
随机推荐
手机炒股开户安不安全?
Resource scheduling and task scheduling of spark
State machine program framework
Chrome devtools
買賣股票費用計算
1182:合影效果
Guangzhou: new financial activities and new opportunities for enterprises
How to solve the problem of high concurrency and seckill
玩玩sftp上传文件
MATLAB小技巧(20)矩阵分析--主成分回归
[share OpenGL tutorial]
Apiccloud, together with 360 Tianyu, helps enterprises keep the "first pass" of APP security
Maintenance and protection of common faults of asynchronous motor
Characteristics and prevention of electrical fire
电子元器件销售ERP管理系统哪个比较好?
Boundary value analysis method for learning basic content of software testing (2)
The Cassandra cluster reinstalls and starts from the node. An error is reported. There is an existing solution
Privacy computing fat----- offline prediction
从知识到智慧:知识图谱还要走多远?
Data modeling based on wide table