Skip to content

Commit fb5fd9e

Browse files
committed
[aceptaelreto] Add C++ solution for 107 - Aproximación de Gauss
1 parent 4426921 commit fb5fd9e

File tree

4 files changed

+43
-0
lines changed

4 files changed

+43
-0
lines changed

aceptaelreto/107-1.ans

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Mayor
2+
Mayor
3+
Menor
4+
Mayor
5+
Mayor
6+
Menor

aceptaelreto/107-1.in

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
10 3
2+
750 2
3+
65535 2
4+
65535 3
5+
10000 2
6+
99999 1
7+
0 0

aceptaelreto/107.cc

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// https://www.aceptaelreto.com/problem/statement.php?id=106
2+
#include <bits/stdc++.h>
3+
4+
using namespace std;
5+
const int N = 100000;
6+
bool composite[N];
7+
int pi[N];
8+
9+
int main() {
10+
cin.tie(0), ios::sync_with_stdio(0);
11+
for (int i = 4; i < N; i += 2) composite[i] = 1;
12+
for (int i = 3; i < N; i += 2)
13+
if (!composite[i])
14+
for (int j = i * 2; j < N; j += i) composite[j] = 1;
15+
for (int i = 2; i < N; i++) pi[i] = pi[i - 1] + !composite[i];
16+
int n, m;
17+
while (1) {
18+
cin >> n >> m;
19+
if (!n && !m) break;
20+
double error = pi[n] / double(n) - 1 / log(double(n));
21+
if (error < 0) error = -error;
22+
for (int i = 0; i < m; i++) error *= 10;
23+
if (error == 1) cout << "Igual\n";
24+
else if (error < 1)
25+
cout << "Menor\n";
26+
else
27+
cout << "Mayor\n";
28+
}
29+
}

aceptaelreto/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ There are solutions for the following
1010
1. [104 - Móviles](104.cc) ([problem site](https://www.aceptaelreto.com/problem/statement.php?id=104))
1111
1. [105 - Ventas](105.cc) ([problem site](https://www.aceptaelreto.com/problem/statement.php?id=105))
1212
1. [106 - Códigos de barras](106.cc) ([problem site](https://www.aceptaelreto.com/problem/statement.php?id=106))
13+
1. [107 - Aproximación de Gauss](107.cc) ([problem site](https://www.aceptaelreto.com/problem/statement.php?id=107))
1314
1. [114 - Último dígito del factorial](114.cc) ([problem site](https://www.aceptaelreto.com/problem/statement.php?id=114))
1415
1. [116 - ¡Hola mundo!](116.cc) ([problem site](https://www.aceptaelreto.com/problem/statement.php?id=116))
1516
1. [192 - Por 3 o más 5](192.cc) ([problem site](https://www.aceptaelreto.com/problem/statement.php?id=192))

0 commit comments

Comments
 (0)