Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include<string>
- #include<cstdbool>
- using namespace std;
- void solve ();
- long double d(long double a , long double b, long double c);
- int main()
- {
- int t = 1;
- //cin >> t; //x=t;
- while (t--) {
- solve();
- }
- return 0;
- }
- void solve() {
- int m; cin >> m;
- long double di[110];
- for (int i = 1; i <= m; ++i)
- {
- cin >> di[i];
- }
- int n; cin >> n;
- for (int i = 0; i < n; ++i)
- {
- long double a, b, c; cin >> a >> b >> c;
- bool f[110];
- fill (f, f + 105, 0);
- int count = 0;
- int j;
- for (int j = 1; j <= m; ++j)
- {
- if (d(a, b, c) <= di[j]) {
- f[j] = 1;
- count++;
- }
- }
- if (!count) cout << "Peg " << (char) ('A' + i) << " will not fit into any holes" << endl;
- else {
- cout << "Peg " << (char) ('A' + i) << " will fit into hole(s):";
- for (int k = 1; k <= m; k++) {
- if (f[k]) {
- cout << " " << k;
- }
- }
- cout << endl;
- }
- }
- }
- long double d(long double a , long double b, long double c) {
- long double s = (a + b + c) / 2.0;
- long double area = (long double) sqrt(s * (s - a) * (s - b) * (s - c) * 1.0);
- long double ret = ((a * b * c * 1.0) / 2.0) / area;
- return ret;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement