-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path10200.cpp
More file actions
37 lines (34 loc) · 723 Bytes
/
10200.cpp
File metadata and controls
37 lines (34 loc) · 723 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
#include <bits/stdc++.h>
using namespace std;
bool prime(long n) {
long i;
if (n == 2)
return 0;
else if (n % 2 == 0)
return 1;
for (i = 3; i * i <= n; i++)
if (n % i == 0) return 1;
return 0;
}
int main() {
long long k, i;
int b, c;
double avg;
int a[10002];
a[0] = 0;
a[1] = 1;
for (i = 1; i <= 10000; i++) {
k = (i * i) + i + 41;
if (!prime(k))
a[i + 1] = a[i] + 1;
else
a[i + 1] = a[i];
}
while (scanf("%d %d", &b, &c) == 2) {
k = a[c + 1] - a[b];
i = c - b + 1;
avg = ((k / (double)i) * 100.0) + .0000000001;
printf("%.2lf\n", avg);
}
return 0;
}