fork download
  1. #include <iostream>
  2. #include <sstream>
  3. #include <fstream>
  4. #include <string>
  5. #include <vector>
  6. #include <deque>
  7. #include <queue>
  8. #include <stack>
  9. #include <set>
  10. #include <map>
  11. #include <algorithm>
  12. #include <functional>
  13. #include <utility>
  14. #include <bitset>
  15. #include <cmath>
  16. #include <cstdlib>
  17. #include <ctime>
  18. #include <cstdio>
  19.  
  20. using namespace std;
  21.  
  22. #define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
  23. #define snuke(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
  24.  
  25. double func(double w, double h, double theta){
  26. double bound = atan2(h, w) * 2.0;
  27. if(theta > bound) return 4.0 * h * h / sin(theta);
  28. double ans = 4.0 * w * h;
  29. // d1 * (1.0 + cos(theta)) + d2 * sin(theta) = 2.0 * w
  30. // d1 * sin(theta) + d2 * (1.0 + cos(theta)) = 2.0 * h
  31. double d1 = (2.0 * w * (1.0 + cos(theta)) - 2.0 * h * sin(theta)) / ((1.0 + cos(theta)) * (1.0 + cos(theta)) - sin(theta) * sin(theta));
  32. double d2 = (2.0 * h * (1.0 + cos(theta)) - 2.0 * w * sin(theta)) / ((1.0 + cos(theta)) * (1.0 + cos(theta)) - sin(theta) * sin(theta));
  33. ans -= d1 * d1 * sin(theta) * cos(theta);
  34. ans -= d2 * d2 * sin(theta) * cos(theta);
  35. return ans;
  36. }
  37.  
  38. int main(void){
  39. int w,h,alpha;
  40.  
  41. cin >> w >> h >> alpha;
  42.  
  43. if(alpha > 90) alpha = 180 - alpha;
  44. double theta = alpha / 180.0 * acos(-1.0);
  45. if(w < h) swap(w, h);
  46.  
  47. double ans = func(w / 2.0, h / 2.0, theta);
  48. printf("%.9f\n", ans);
  49.  
  50. return 0;
  51. }
Success #stdin #stdout 0s 2856KB
stdin
Standard input is empty
stdout
4039843242167511552.000000000