UVA 10200 Prime Time (打表)

时间:2023-03-09 03:09:46
UVA 10200 Prime Time (打表)

题目链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1141

Sample Input

Sample Output
100.00
97.56
50.00
 #include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <stack>
#include <map>
#include <vector>
using namespace std; #define N 12000
#define INF 0x3f3f3f3f int f[N]; int q(long long m)
{
int k=(int)sqrt(m);
for(int i=;i<=k;i++)
if(m%i==)
return ;
return ;
} int main()
{
int a,b;
f[]=; for(int i=;i<N;i++)
f[i]=f[i-]+q(i*i+i+); while(scanf("%d%d", &a,&b) != EOF)
{
double s;
if(a==)
s=1.0*f[b]/(b-a+);
else
s=1.0*(f[b]-f[a-])/(b-a+);
printf("%.2f\n", s*+1e-);
} return ;
}