Advertisement
Saleh127

UVA 10573

Mar 22nd, 2021
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define pi acos(-1.0)
  5. int main()
  6. {
  7. ios_base::sync_with_stdio(0);
  8. cin.tie(0);
  9. cout.tie(0);
  10.  
  11. string a;
  12.  
  13. int t;
  14.  
  15. cin>>t;
  16.  
  17. getline(cin,a);
  18.  
  19. for(int cs=1; cs<=t; cs++)
  20. {
  21.  
  22.  
  23. ll b,c,i,j,k,l=0;
  24.  
  25. getline(cin,a);
  26.  
  27. for(i=0; i<a.size(); i++)
  28. {
  29. if(a[i]==' ')
  30. {
  31. l=i;
  32. break;
  33. }
  34. }
  35.  
  36. double x,r,r1,r2,s;
  37.  
  38. if(l==0)
  39. {
  40. b=0;
  41. for(i=0; i<a.size(); i++)
  42. {
  43. b=b*10+(a[i]-'0');
  44. }
  45.  
  46. x=b*1.00;
  47.  
  48. r=x/2.00;
  49.  
  50. r1=r2=x/4.00;
  51.  
  52. }
  53. else
  54. {
  55. b=c=0;
  56. for(i=0; i<l; i++)
  57. {
  58. b=b*10+(a[i]-'0');
  59. }
  60. l++;
  61. for(i=l; i<a.size(); i++)
  62. {
  63. c=c*10+(a[i]-'0');
  64. }
  65.  
  66. r1=b*1.00;
  67. r2=c*1.00;
  68.  
  69. r=(r1*2.00)+(r2*2.00);
  70. r/=2.00;
  71.  
  72. }
  73.  
  74. s=pi*r*r;
  75. s=s-(pi*r1*r1)-(pi*r2*r2);
  76.  
  77. cout<<fixed<<setprecision(4)<<s<<endl;
  78. }
  79.  
  80.  
  81. return 0;
  82. }
  83.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement