|
|
back to boardCorrect answer but WA#1 Hello. I have WA on the test #1. but answer of my prog with input 4 72 30 50 is 120.00. Here is my code on VS 2010 C++: #include <iostream> #include <vector> #include <math.h> #include <algorithm> #include <iomanip> using namespace std; double slip(double w1, int w2){ double res = 2*(pow(w1*w2, 1.0/2)); return res; } int main(int argc, char *argv[]) { int n; int i; int weight; double ans; vector <int> weights; cin >> n; for (i=0; i<n; i++){ cin >> weight; weights.push_back(weight); } sort(weights.begin(), weights.end()); ans = weights[n-1];
for(i=n-2; i>0; i--){ ans=slip(ans, weights[i]); } cout.precision(2); cout<<fixed<<ans<<endl; //printf("%.2f\n", ans); return 0; } ... As you see i also tried printf but actualy it doesn't work! Edited by author 21.01.2014 02:42 |
|
|