Saturday, June 6, 2015

LightOJ - 1022 - Circle in Square

  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. const double pi = 2*acos(0.0);
  5.  
  6. int main(){
  7.     int t, cs = 0;
  8.     double r, ans, sq, c;
  9.     cin >> t;
  10.     while(t--){
  11.         cin >> r;
  12.         sq = (r*2)*(r*2);
  13.         c = pi*r*r;
  14.         ans = sq - c;
  15.         cout << "Case " << ++cs << ": " << fixed << setprecision(2) << ans << endl;
  16.     }
  17.     return 0;
  18. }

No comments:

Post a Comment