当前位置:网站首页>P2393 yyy loves Maths II
P2393 yyy loves Maths II
2022-06-26 12:37:00 【暴揍键盘的程序猿】
P2393 yyy loves Maths II
# yyy loves Maths II
## 题目背景
上次蒟蒻 redbag 可把 yyy 气坏了,yyy 说他只是小学生,蒟蒻 redbag 这次不坑他了。
## 题目描述
redbag 给了 yyy 很多个数,要 yyy 计算这些数的和。
必须要快,redbag 只给了 yyy $1$ 秒的时间!!!
## 输入格式
一行,很多个数。
## 输出格式
一行,一个实数(四舍五入精确到 $5$ 位小数),表示这些数的和。
## 样例 #1
### 样例输入 #1
```
1
```
### 样例输出 #1
```
1.00000
```
## 提示
对于 $100\%$ 的数据,所有数 $ \le 233,333,333 $,保证在小数点后最多有 $6$ 位数,最多共有 $5\times 10^4$ 个数。
【70分代码】
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<string>
#include<vector>
using namespace std;
const int N=1e5+10;
double n,ans;
signed main()
{
while(cin>>n)ans+=n;
cout<<fixed<<setprecision(5)<<ans;
return 0;
}做完时还在感叹这题太简单了,结果就......

【AC代码】
然后下了个数据突然想到精度不够,换成long double还是不妥。想来想去突然想到可以把小数转换成整数来加,于是......
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<string>
#include<vector>
using namespace std;
const int N=1e6;
long double n,ans;
signed main()
{
while(cin>>n)ans+=n*N;
cout<<fixed<<setprecision(5)<<ans/N;
return 0;
}
边栏推荐
- Photoshop 2022 23.4.1增加了哪些功能?有知道的吗
- PHP generate order number
- Sharing ideas for a quick switch to an underlying implementation
- Lodash common methods (filtering, anti shake...)
- processing 函数translate(mouseX, mouseY)学习
- guacamole安装
- processing 随机生成线动画
- 小白懒人专用-win10-win11一键安装版
- Less than 40 lines of code to create a blocprovider
- QT .pri 的建立与使用
猜你喜欢

The laravel dingo API returns a custom error message

小白懒人专用-win10-win11一键安装版

Tiger DAO VC产品正式上线,Seektiger生态的有力补充

【网络是怎么连接的】第二章(下):一个网络包的接收

Deeply analyze the differences between dangbei box B3, Tencent Aurora 5S and Xiaomi box 4S

快手实时数仓保障体系研发实践

power designer - 自定义注释按钮

Learning Processing Zoog

NoSQL mongodb - 01 introduction to NoSQL and mongodb

Fengshentai old shooting range Kali series
随机推荐
Tiger DAO VC产品正式上线,Seektiger生态的有力补充
Tiger Dao VC products are officially launched, a powerful supplement to seektiger ecology
机组实践实验8——使用CMStudio设计基于基本模型机微程序指令(1)
NoSQL mongodb - 04 mongodb database and web service combination case
Less than 40 lines of code to create a blocprovider
7-2 数的三次方根
手把手带你学会Odoo OWL组件开发(7):OWL项目实战使用
环形队列php
无人机遥感在森林监测的部分应用研究案例总结
Word文档导出(使用固定模板)
洛谷P3426 [POI2005]SZA-Template 题解
Deeply analyze the differences between dangbei box B3, Tencent Aurora 5S and Xiaomi box 4S
7-3 最低通行费
Tiger DAO VC产品正式上线,Seektiger生态的有力补充
【网络是怎么连接的】第二章(上): 建立连接,传输数据,断开连接
JS get the current screen height method and listen for DOM elements to enter the viewport
Php+laravel5.7 use Alibaba oss+ Alibaba media to process and upload image / video files
Lodash common methods (filtering, anti shake...)
Why is password salt called "salt"? [Close] - why is a password salt called a "salt"? [closed]
软件测试测试常见分类有哪些?