-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path3.cpp
More file actions
45 lines (35 loc) · 802 Bytes
/
3.cpp
File metadata and controls
45 lines (35 loc) · 802 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include "iostream"
#include "random"
#include "chrono"
std::mt19937 rng(std::chrono::steady_clock::now().time_since_epoch().count());
void FillArr(double *a,int n) {
std::uniform_real_distribution<double> dist(1.0,100.0);
for (int i = 0.0; i < n; i++) {
a[i] = dist(rng);
}
}
void Solution(const double* a, const int n) {
double prod = 1.0;
for (int i = 0; i < n; i++) {
if ((i & 1) == 0) {
prod *= a[i];
// std::cout<<i<<"\n";
}
}
// for (int i = 0; i < n; i++) {
// std::cout << a[i] << ", ";
// }
std::cout << prod;
}
void solve() {
int n;
std::cin>>n;
auto* arr = new double[n];
FillArr(arr, n);
Solution(arr, n);
delete[] arr;
}
int main() {
solve();
return 0;
}