标签:print stream blog ret space 简单贪心 code main name
思路:
简单贪心。
实现:
1 #include <iostream> 2 #include <cstdio> 3 #include <algorithm> 4 #include <cmath> 5 using namespace std; 6 7 int a[105], n; 8 9 bool cmp(const int & a, const int & b) 10 { 11 return a > b; 12 } 13 14 int main() 15 { 16 cin >> n; 17 for (int i = 0; i < n; i++) 18 { 19 cin >> a[i]; 20 } 21 sort(a, a + n, cmp); 22 double res = a[0]; 23 for (int i = 0; i < n - 1; i++) 24 { 25 res = 2.0 * sqrt(res * a[i + 1]); 26 } 27 printf("%.3f\n", res); 28 return 0; 29 }
标签:print stream blog ret space 简单贪心 code main name
原文地址:http://www.cnblogs.com/wangyiming/p/6579550.html