当前位置:网站首页>P2393 yyy loves Maths II
P2393 yyy loves Maths II
2022-06-26 13:03:00 【A program ape who smashes the keyboard】
P2393 yyy loves Maths II
# yyy loves Maths II
## Background
Last time konjak redbag Can handle yyy I'm so angry ,yyy Said he was just a pupil , Konnyaku redbag Don't pit him this time .
## Title Description
redbag Give it to yyy A lot of numbers , want yyy Calculate the sum of these numbers .
Must be fast ,redbag Only for yyy $1$ The second time !!!
## Input format
a line , A lot of numbers .
## Output format
a line , A real number ( Round to the nearest $5$ Decimal place ), Represents the sum of these numbers .
## Examples #1
### The sample input #1
```
1
```
### Sample output #1
```
1.00000
```
## Tips
about $100\%$ The data of , All numbers $ \le 233,333,333 $, Ensure that there are at most... After the decimal point $6$ digit , Most in common $5\times 10^4$ Number .
【70 Code division 】
#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;
}When I finished, I still exclaimed that the problem was too simple , The result is ......

【AC Code 】
Then the next data suddenly thought that the accuracy was not enough , Switch to long double It's still not right . think it over and over again It suddenly occurred to me that I could convert decimals into integers to add , therefore ......
#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;
}
边栏推荐
- 倍福PLC基于NT_Shutdown实现控制器自动关机重启
- Record a phpcms9.6.3 vulnerability to use the getshell to the intranet domain control
- NoSQL mongodb - 01 introduction to NoSQL and mongodb
- 软件测试 - 概念篇
- BigInt:处理大数字(任意长度的整数)
- Websocket and socket IO case practice
- Software testing - concept
- 倍福Ethercat模块网络诊断和硬件排查的基本方法
- Is it safe for the head teacher to open a stock account and open an account for financial management?
- Detailed explanation of C const: definition and use of C constant
猜你喜欢
RSS rendering of solo blog system failed

Openlayers drawing dynamic migration lines and curves

倍福TwinCAT通过Emergency Scan快速检测物理连接和EtherCAT网络

How does easygbs solve the abnormal use of intercom function?

ES6模块

EasyGBS如何解决对讲功能使用异常?

四类线性相位 FIR滤波器设计 —— MATLAB源码全集

Learning Processing Zoog

【网络是怎么连接的】第一章:浏览器生成消息

Echart堆叠柱状图:色块之间添加白色间距效果设置
随机推荐
倍福PLC基于NT_Shutdown实现控制器自动关机重启
. Net Maui performance improvement
How does easygbs solve the abnormal use of intercom function?
由错误<note: candidate expects 1 argument, 0 provided>引发的思考
Group counting practice experiment 9 -- using cmstudio to design microprogram instructions based on segment model machine (2)
心脏滴血漏洞(CVE-2014-0160)分析与防护
Power Designer - Custom Comment button
Summary of some application research cases of UAV Remote Sensing in forest monitoring
postgis计算角度
Beifu PLC passes MC_ Readparameter read configuration parameters of NC axis
Solution of Splunk iowait alarm
倍福Ethercat模块网络诊断和硬件排查的基本方法
面试题积累
National standard gb28181 protocol easygbs video platform TCP active mode streaming exception repair
倍福NC轴状态转移图解析
详细讲解C语言10(C语言系列)
数字信号处理——线性相位型(Ⅰ、Ⅲ型)FIR滤波器设计(1)
Is it safe for the head teacher to open a stock account and open an account for financial management?
Redis learning - 02 common data types, operation commands and expiration time
Adobe Acrobat阻止30款安全软件查看PDF文件 或存在安全风险