当前位置:网站首页>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方块人
边栏推荐
- Common test method used by testers --- orthogonal method
- 104. maximum depth of binary tree
- 如何抑制SiC MOSFET Crosstalk(串擾)?
- 手机炒股开户安不安全?
- Construire le premier réseau neuronal avec pytorch et optimiser
- Key points of building fire protection design
- DEJA_VU3D - Cesium功能集 之 051-地形开挖完美实现
- Large current and frequency range that can be measured by Rogowski coil
- MATLAB小技巧(20)矩阵分析--主成分回归
- Music website design based on harmonyos (portal page)
猜你喜欢

数据挖掘建模实战

redis5.0的槽点迁移,随意玩(单机迁移集群)

Using transform:scale causes the page mouse hover event to disappear

从知识到智慧:知识图谱还要走多远?

股票 停牌
![[big case] Xuecheng online website](/img/40/beec3ba567f5a372899bb58af0d05a.png)
[big case] Xuecheng online website

用Pytorch搭建第一個神經網絡且進行優化

Discussion on safety management of centralized maintenance construction site of substation under the mode of operation and maintenance

Data mining modeling practice

new URL(“www.jjj.com“)
随机推荐
Application of energy management system in iron and steel enterprises
Implement global double finger long press to return to the desktop
spark的资源调度和任务调度
Protection range and optimization of motor protector for hoist equipment
SQL 优化经历:从 30248秒到 0.001秒的经历
用Pytorch搭建第一個神經網絡且進行優化
Campus honey decoration of APP course design (e-commerce platform)
Find the total number of 1 appearing in the integer 1-N and the number of 1 in the binary of the integer
Installation of containerd1.5.5
Implementation of single sign on
Data mining modeling practice
How do I open an account on my mobile phone? Is it safe to open an account online now?
Common test method used by testers --- orthogonal method
Ffmpeg streaming fails to update header with correct duration
Implementation of single sign on
Calculation of stock purchase and sale expenses
如何抑制SiC MOSFET Crosstalk(串擾)?
1182:合影效果
Loggerfactory uses log4j Parameter introduction of properties
Error: `brew cask` is no longer a `brew` command. Use `brew <command> --cask` instead.