poj1491
簡單題
View Code #include <iostream> #include <cstdlib> #include <cstdio> #include <cstring> #include <cmath> using namespace std;#define maxn 55int n; int f[maxn];int gcd(int a, int b) {if (b > 0)return gcd(b, a % b);return a; }void input() {for (int i = 0; i < n; i++)scanf("%d", &f[i]); }void work() {int numerator = 0;for (int i = 0; i < n; i++)for (int j = i + 1; j < n; j++)if (gcd(f[i], f[j]) == 1)numerator++;if (numerator == 0){printf("No estimate for this data set.\n");return;}printf("%.6f\n", sqrt(n * (n - 1) * 3.0 / numerator)); }int main() { // freopen("t.txt", "r", stdin);while (scanf("%d", &n), n){input();work();}return 0; }?
總結
- 上一篇: 常用移动web开发框架
- 下一篇: android 一些常用的功能方法代码块