Advertisement
Hasan1026

Dhuka Dhuki

Jan 11th, 2021
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.19 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include<string>
  4. #include<cstdbool>
  5. using namespace std;
  6. void solve ();
  7. long double d(long double a , long double b, long double c);
  8. int main()
  9. {
  10.     int t = 1;
  11.     //cin >> t; //x=t;
  12.     while (t--) {
  13.         solve();
  14.     }
  15.     return 0;
  16. }
  17.  
  18. void solve() {
  19.     int m; cin >> m;
  20.     long double di[110];
  21.     for (int i = 1; i <= m; ++i)
  22.     {
  23.         cin >> di[i];
  24.     }
  25.     int n; cin >> n;
  26.     for (int i = 0; i < n; ++i)
  27.     {
  28.         long double  a, b, c; cin >> a >> b >> c;
  29.         bool f[110];
  30.         fill (f, f + 105, 0);
  31.         int count = 0;
  32.         int j;
  33.         for (int j = 1; j <=  m; ++j)
  34.         {
  35.             if (d(a, b, c) <= di[j]) {
  36.                 f[j] = 1;
  37.                 count++;
  38.             }
  39.         }
  40.         if (!count) cout << "Peg " << (char) ('A' + i) << " will not fit into any holes" << endl;
  41.         else {
  42.             cout << "Peg " << (char) ('A' + i) << " will fit into hole(s):";
  43.             for (int k = 1; k <= m; k++) {
  44.                 if (f[k]) {
  45.                     cout << " " << k;
  46.                 }
  47.             }
  48.             cout << endl;
  49.         }
  50.     }
  51.  
  52.  
  53. }
  54. long double d(long double a , long double b, long double c) {
  55.     long double s = (a + b + c) / 2.0;
  56.     long double area = (long double) sqrt(s * (s - a) * (s - b) * (s - c) * 1.0);
  57.     long double ret = ((a * b * c * 1.0) / 2.0) / area;
  58.     return ret;
  59. }
  60.  
  61.  
  62.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement