rendered paste body#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
double sinus(int,int),a,b,c,m,n,p,k;
int main()
{
setlocale(0,"");
cout.precision(36);
cin >> a >> b >> c >> m >> n >> p;
double t;
t=0.01*a+0.001*b+0.0001*c;
cout <<setw(7)<< "t=" << t << endl;
double MP, MK;
MK=sqrt(pow((a-n),2)+ pow(b,2)+ pow((c-m-p),2));
MP = MK - n * t;
k = a - n - sqrt(pow(MP,2) - pow(b,2) - pow((c-m-p),2));
cout << setw(7)<<"k=" << k << endl;
double P3M, tP3M;
P3M = sqrt(pow((c-m-p),2) + pow((a-n+b+k),2));
cout << setw(7)<< "P3M=" << P3M << endl;
tP3M = P3M / n * b;
cout << setw(7)<<"tP3M=" << tP3M << endl;
double P4M, tP4M;
P4M = sqrt(pow((c-m-p),2) + pow((n+b+a-k),2));
cout << setw(7)<<"P4M=" << P4M << endl;
tP4M = P4M / n * b;
cout <<setw(7)<< "tP4M=" << tP4M << endl;
// находим sina1:
double sina1=sinus(1,int(c));
cout <<setw(7)<< "sina1=" << sina1 << endl;
// находим tP1M:
double tP1M;
tP1M=(m+c-p)*b/n/sqrt(1-sina1*sina1)+b*c/n/sqrt(1-pow((b/c*sina1),2));
cout <<setw(7)<< "tP1M=" << tP1M <<" без учета принципа Ферма t="<<(m+c-p+b)/sqrt(1-sina1*sina1)/n*c<< endl;
// находим sina2:
double sina2=sinus(-1,int(a));
cout <<setw(7)<< "sina2=" << sina2 << endl;
// находим tP1M:
double tP2M;
tP2M=(c-m+p)*b/n/sqrt(1-sina2*sina2) + b*b/n/sqrt(1-pow((b/a*sina2),2));
cout << setw(7)<<"tP2M=" <<tP2M <<" без учета принципа Ферма t=" << (c-m+p+b*b/a)/sqrt(1-sina2*sina2)/n*a << endl;
double tmin;
tmin=min(min(tP1M,tP2M),min(tP3M,tP4M));
cout << setw(7)<<"tmin=" << tmin << endl;
double L;
L=n*tmin;
cout << setw(7)<<"L=" << L << endl;
// по какому пути быстрее:
if(tmin==tP1M)cout << endl << "\"ПОЛ\"";
if(tmin==tP2M)cout << endl << "\"ПОТОЛОК\"";
if(tmin==tP3M)cout << endl << "\"ПРАВЫЙ\"";
if(tmin==tP4M)cout << endl << "\"ЛЕВЫЙ\"";
cout << endl;
system ("pause");
return 0;
}
double sinus(int s,int f)
{
double sina, nach=0.99999, mnog=1.0, vir;
int i=0;
a: for (sina=nach; sina>0; sina-=0.1/mnog){
vir=sina*((s*m+c-s*p)/sqrt(1-pow(sina,2))+pow(b,2)/f/sqrt(1-pow((b*sina/f),2)));
if (vir<(a-n-k)){
nach=sina+0.2/mnog;
mnog*=10;
i++;
if (i==10)break;
goto a;
}
}
return sina;
}