Created
January 2, 2019 15:34
-
-
Save nukopy/722819f932cd6a8350a64b0e37d96c42 to your computer and use it in GitHub Desktop.
ABC026: B - N重丸
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <cstdio> | |
#include <string> | |
#include <vector> | |
#include <iterator> // std::back_inserter() | |
#include <set> | |
#include <map> | |
#include <algorithm> // std::copy() | |
#include <functional> // std::greater<T>() | |
#include <utility> // std::swap() | |
#include <numeric> // accumulate(ALL(vec), 0) 0 は初期値 | |
#include <cmath> | |
#include <climits> // INT_MIN | |
#include <iomanip> // std::setprecision() | |
using namespace std; | |
#define REP(i, n) for (int i=0; i < (int)(n); i++) // 0 ~ n-1 | |
int main() { | |
cin.tie(0); | |
ios::sync_with_stdio(false); | |
// input | |
ll N; | |
cin >> N; | |
vector<int> vec(N); | |
REP(i, N) cin >> vec[i]; | |
// calculation | |
sort(vec.begin(), vec.end(), greater<int>()); // int big -> small | |
double sum = 0, pi = M_PI; | |
for (int i = 0; i < N; ++i) { | |
if (i%2 == 0) { | |
sum += (double)pow(vec[i], 2); | |
} else { | |
sum -= (double)pow(vec[i], 2); | |
} | |
} | |
int max_digit = 6, precision = 6 + 1; | |
cout << setprecision(max_digit + precision) << sum*pi << "\n"; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment