当前位置:网站首页>L1-068 harmonic average (10 points)
L1-068 harmonic average (10 points)
2022-06-12 04:27:00 【Liabilities between persons^】
L1-068 Harmonic mean (10 branch )
N The arithmetic average of positive numbers is the sum of these numbers divided by N, Their harmonic mean is the reciprocal of their reciprocal arithmetic mean . Please calculate the harmonic average of a given series of positive numbers .
Input format :
Each input contains 1 Test cases . Each test case is No 1 Line gives a positive integer N (≤1000); The first 2 Line is given N It's a positive number , It's all in the range [0.1,100] Inside .
Output format :
Output the harmonic average of a given sequence in one row , Output after decimal point 2 position .
sample input :
8
10 15 12.7 0.3 4 13 1 15.6
sample output :
1.61
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<sstream>
using namespace std;
typedef long long ll;
const int N=10010;
int main()
{
int n;
cin >> n;
double sum = 0;
for(int i = 0; i < n; i ++ )
{
double x;
cin >> x;
sum += 1.0 / x;
}
cout << sum << endl;
printf("%.2lf",1.0 / (sum / n));
return 0;
}
边栏推荐
- mysqld: Can‘t create directory ‘D: oftinstall\mysql57 (Errcode: 2 - No such file or directory)
- 疫情数据分析平台工作报告【1】数据采集
- Smart Panel wifi Linkage Technology, esp32 wireless chip module, Internet of Things WiFi Communication Application
- Epidemic data analysis platform work report [3] website deployment
- MySQL master-slave construction and Django implementation of read-write separation
- [issue 31] 360 background development practice experience - two rounds of technical aspects
- 动规(15)-最低通行费
- QT compiling security video monitoring system 43- picture playback
- Construction case of Expressway Precast Beam Yard (with scheme text)
- 疫情数据分析平台工作报告【6】可视化绘图
猜你喜欢

疫情数据分析平台工作报告【6.5】疫情地图

【FPGA+FFT】基于FPGA的FFT频率计设计与实现

The memory four area model of C language program

Why should a redis cluster use a reverse proxy? Just read this one

Recommended system cleaning tools, cocktail Download

QT compiling security video monitoring system 43- picture playback

Smart panel WiFi linkage technology, esp32 wireless chip module, Internet of things WiFi communication application

Notes on relevant knowledge points such as original code / inverse code / complement code, size end, etc

【C语言】变量本质分析
![[automation] generate xlsx report based on openstack automated patrol deployed by kolla](/img/65/f062a6a1080c42857466f13e67fef1.jpg)
[automation] generate xlsx report based on openstack automated patrol deployed by kolla
随机推荐
Oracle:decode function
Install/Remove of the Service Denied!
Thousand word masterpiece "programming biography"
QT experiment - gold coin flipping games
疫情数据分析平台工作报告【1】数据采集
How to use union all in LINQ- How to use union all in LINQ?
Mysql主从搭建与Django实现读写分离
Ebpf series learning (4) learn about libbpf, co-re (compile once – run everywhere) | use go to develop ebpf programs (cloud native tool cilium ebpf)
【C语言】封装接口(加减乘除)
DS18B20数字温度计 (一) 电气特性, 供电和接线方式
Enterprise Architect v16
Double objective learning materials sorting
MFC General dialog color dialog
How to make datasets, train them into models and deploy them based on yolov5
How Windows installs multiple versions of MySQL and starts it at the same time
【C语言】变量本质分析
leetcode797. All possible paths (medium)
基于SSH实现健身俱乐部管理系统
【高效】最强开发工具Ctool编译踩坑
C# Task. Waitall method