当前位置:网站首页>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;
}
边栏推荐
- How to use union all in LINQ- How to use union all in LINQ?
- Database selected 60 interview questions
- 请用递归的方法计算下列函数的值:px(x,n)=x-x^2 +x^3- x^4+… ((-1)n-1)(xn) n>0 **输入格式要求:“%lf%d“ 提示信息:“Enter X and N:”
- From science to startup
- How Windows installs multiple versions of MySQL and starts it at the same time
- Using datetime in MySQL
- R language write function: use the write function to write data to the rstudio console, and the write function to write data to a new rstudio window (start a new window)
- 疫情数据分析平台工作报告【1】数据采集
- Question for the 3D printing lattice?
- Thousand word masterpiece "programming biography"
猜你喜欢

Oracle's instr()

疫情数据分析平台工作报告【7】阿里云相关

2.28 (defect filling) data type conversion exception handling part multi threading

DS18B20 digital thermometer (I) electrical characteristics, power supply and wiring mode

What are the black box test case design methods in software testing methods?

Brief introduction to 44 official cases of vrtk3.3 (combined with steamvr)

Raspberry pie 4B uses Intel movidius NCS 2 for inference acceleration

Zabbix6.0 new feature GEOMAP map marker can you use it?

Recommended system cleaning tools, cocktail Download
![Epidemic data analysis platform work report [2] interface API](/img/63/383d52775790920bd2467d7ecacfe5.png)
Epidemic data analysis platform work report [2] interface API
随机推荐
【FPGA+GPS接收器】基于FPGA的双频GPS接收器详细设计介绍
疫情数据分析平台工作报告【3】网站部署
R language plot visualization: plot visualization of basic 2D histogram, custom setting of color of 2D histogram, and histogram visualization of binary distribution (basic 2D histogram)
Detailed explanation of Command Execution Vulnerability
Smart panel WiFi linkage technology, esp32 wireless chip module, Internet of things WiFi communication application
Illustrating the use of Apache skywalking UI
疫情数据分析平台工作报告【8.5】额外的爬虫和绘图
Ebpf series learning (4) learn about libbpf, co-re (compile once – run everywhere) | use go to develop ebpf programs (cloud native tool cilium ebpf)
R language write function: use the write function to write data to the rstudio console, and the write function to write data to a new rstudio window (start a new window)
路灯照明物联网技术方案,ESP32-S3芯片通信应用,智能WiFi远程控制
Kotlin协程协程作用域,CoroutineScope MainScope GlobalScope viewModelScope lifecycleScope 分别代表什么
D1 哪吒开发板 上电记录
Work report of epidemic data analysis platform [6.5] epidemic map
[C language] analysis of variable essence
数据库新建表,以前没问题的,今天
疫情数据分析平台工作报告【7】阿里云相关
Please calculate the value of the following function recursively: PX (x, n) =x-x^2 +x^3- x^4+... (-1) n-1) (xn) n > 0 * * input format requirements: "%lf%d" prompt: "enter X and n:"
JSP implementation of bank counter business performance evaluation system
Street lighting IOT technology scheme, esp32-s3 chip communication application, intelligent WiFi remote control
R语言plotly可视化:plotly可视化基础二维直方图、自定义设置二维直方图的颜色、二维直方图是二元分布的直方图可视化(Basic 2D Histogram)