Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cmath>
- #include <iostream>
- #define _USE_MATH_DEFINES
- using namespace std;
- typedef long double ld;
- typedef long long ll;
- long double e = 10e-3;
- int m = 3;
- double g = 9.81;
- ld cx2, cx1, cx0, cy2, cy1, cy0, v, o, ro = 1.225, s = 0.36;
- ld f(ld a) {
- ld alfa = a;
- ld alfarad = a * M_PI / 180;
- ld b = m * g * cos(o) - (((cy0 + cy1 * alfa + cy2 * alfa * alfa) * ro * v * v * s) / 2);
- b /= ((((cx0 + cx1 * alfa + cx2 * alfa * alfa) * ro * v * v * s) / 2) + m * g * sin(o));
- return tan(alfarad) - b;
- }
- int main() {
- cin >> cx2 >> cx1 >> cx0;
- cin >> cy2 >> cy1 >> cy0;
- cin >> v >> o;
- v /= 3.6;
- o *= M_PI / 180;
- ld x1, x2, x3, y1, y3;
- ld b;
- x1 = -5;
- x3 = 10;
- ld pcos;
- y1 = f(x1);
- y3 = f(x3);
- if (y1 < 0) {
- while (x1 + e < x3) {
- x2 = (x1 + x3) / 2;
- b = f(x2);
- if (b > 0) {
- x3 = x2;
- }
- if (b < 0) {
- x1 = x2;
- }
- }
- }
- if (y1 > 0) {
- while (x1 + e < x3) {
- x2 = (x1 + x3) / 2;
- b = f(x2);
- if (b > 0) {
- x1 = x2;
- }
- if (b < 0) {
- x3 = x2;
- }
- }
- }
- else
- {
- x2 = x1;
- }
- if (y3 == 0)
- {
- x2 = x3;
- }
- ld x = x2 * 100;
- ld xld = x;
- cout << xld / 100.0 << ' ';
- pcos = ((((cx0 + cx1 * x2 + cx2 * x2 * x2) * ro * v * v * s) / 2) + m * g * sin(o));
- x2 *= M_PI / 180;
- ld p = pcos / cos(x2);
- ld pp = p * 100;
- cout << pp / 100.0 << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement