Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define ll long long
- #include <bits/stdc++.h>
- using namespace std;
- const int OO = 1e9;
- const double EPS = 1e-6;
- bool comp(double x1, double x2) {
- return (fabs(x1-x2) < EPS);
- }
- int main()
- {
- ios_base::sync_with_stdio(false);
- cin.tie(NULL);
- cout.tie(NULL);
- cout.precision(2);
- cout << fixed;
- while(true) {
- double a,b,s,m,n;
- cin >> a >> b >> s >> m >> n;
- if(a == 0)
- break;
- double theta_rad = atan((n*b)/(m*a));
- double theta_deg = (theta_rad*180)/acos(-1);
- cout << theta_deg << " ";
- double time = 0;
- double speed_x = cos(theta_rad);
- double speed_y = sin(theta_rad);
- double init_x = a/2;
- double init_y = b/2;
- double curr_x = a/2;
- double curr_y = b/2;
- //int times = 0;
- //cout << "\n";
- //ms -> time
- //1/x -> s
- //1/x = s*ms
- int k_m = 0;
- int k_n = 0;
- while(!comp(curr_x,init_x) || !comp(curr_y,init_y) || comp(time,0) || k_m < m || k_n < n) {
- //dist += 1;
- //curr_x += speed_x;
- //curr_y += speed_y;
- double curr_t = min((speed_x > 0 ? a-curr_x:curr_x-0)/fabs(speed_x),(speed_y > 0 ? b-curr_y:curr_y-0)/fabs(speed_y));
- double reach_x = (((curr_x < init_x && speed_x > 0)||(curr_x > init_x && speed_x < 0)) ? fabs(curr_x-init_x)/fabs(speed_x):-1);
- double reach_y = (((curr_y < init_y && speed_y > 0)||(curr_y > init_y && speed_y < 0)) ? fabs(curr_y-init_y)/fabs(speed_y):-1);
- bool reached_start = false;
- if(reach_x != -1 && reach_y != -1 && comp(reach_x,reach_y) && reach_x < curr_t) {
- curr_t = reach_x;
- reached_start = true;
- }
- curr_x += speed_x*curr_t;
- curr_y += speed_y*curr_t;
- time += curr_t;
- if(curr_x >= a || curr_x <= 0) {
- speed_x *= -1;
- k_m++;
- }
- if(curr_y >= b || curr_y <= 0) {
- speed_y *= -1;
- k_n++;
- }
- if(reached_start && k_m == m && k_n == n) {
- break;
- }
- //cout << "curr_x is " << curr_x << " curr_y is " << curr_y << "\n";
- //cout << "speed_x is " << speed_x << " speed_y is " << speed_y << "\n";
- //cout << "k_n is " << k_n << " k_m is " << k_m << "\n";
- //times++;
- //if(times == 20)
- //break;
- }
- //cout << "k_n is " << k_n << " k_m is " << k_m << "\n";
- cout << time/s << "\n";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement