Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- // #include <iostream>
- // #include <cstdio>
- // #include <cstdlib>
- // #include <algorithm>
- // #include <cmath>
- // #include <vector>
- // #include <set>
- // #include <map>
- // #include <queue>
- // #include <ctime>
- // #include <cassert>
- // #include <complex>
- // #include <string>
- // #include <cstring>
- // #include <queue>
- // #include <bitset>
- using namespace std;
- // #pragma GCC optimize("Ofast,no-stack-protector")n
- // #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
- // #pragma GCC optimize("unroll-loops")
- #define ll long long int
- #define ull unsigned long long int
- #define vi vector< int >
- #define vll vector< ll >
- #define sc scanf
- #define pf printf
- #define cspf(i) pf("Case %d: ", i)
- #define spc pf(" ")
- #define line pf("\n")
- #define ff first
- #define ss second
- #define mp make_pair
- #define pb push_back
- #define ppb pop_back
- #define tp(v,j) get<j>(v)
- #define Log(b,x) (log(x)/log(b))
- #define FOR(i,x,y) for(int i = int(x); i < int(y); i++)
- #define ROF(i,x,y) for(int i = int(x)-1; i >= int(y); i--)
- #define clr(arr,x) memset(arr, x, sizeof arr)
- #define vout(v) for(int w=0;w<(int)v.size();w++){if(w) spc; cout<<v[w];}
- #define all(v) v.begin(), v.end()
- #define rall(v) v.rbegin(), v.rend()
- #define unq(v) sort(all(v)),(v).resize(unique(all(v))-v.begin())
- #define fastIO ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr)
- #define sc1(x) sc("%d",&x)
- #define sc2(x,y) sc("%d %d", &x, &y)
- #define sc3(x,y,z) sc("%d %d %d", &x, &y, &z)
- #define scl1(x) sc("%lld",&x);
- #define scl2(x,y) sc("%lld %lld", &x, &y)
- #define scf1(x) sc("%lf",&x)
- #define scf2(x,y) sc("%lf %lf", &x, &y)
- #define pf1(x) pf("%d",x)
- #define pf2(x,y) pf("%d %d", x, y)
- #define pf3(x,y,z) pf("%d %d %d", x, y, z)
- #define pfl1(x) pf("%lld",x)
- #define pfl2(x,y) pf("%lld %lld",x,y)
- #define MOD 1000000007
- #define MaxN 200002
- #define MAX (ll)(1e10)
- #define inf 0x3f3f3f3f
- #define PI acos(-1.0) // 3.1415926535897932
- #define eps 1e-6
- template <class T> inline T bigMod(T p,T e,T M){T ret=1; for(;e>0;e>>=1){ if(e&1) ret=(ret*p)%M; p=(p*p)%M;} return (T)ret;}
- template <class T> inline T modInverse(T a,T M){return bigMod(a,M-2,M);}
- template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
- template <class T> inline T lcm(T a,T b) {a=abs(a);b=abs(b); return (a/gcd(a,b))*b;}
- template <class T> inline T SQR(T a){return a*a;}
- int dx[] = { 1,-1, 0, 0}; //graph moves
- int dy[] = { 0, 0, 1,-1}; //graph moves
- double ar[3], a;
- int hor, ver;
- double SQ(double x){ return x*x;}
- double toRadian(double x){ return (x*(PI/180.0));}
- double toDegree(double x){ return (x*(180.0/PI));}
- double lombo(double bhumi, double angle){ return tan(toRadian(angle)) * bhumi;}
- double otibhuj(double lombo, double bhumi){ return sqrt( SQ(lombo) + SQ(bhumi));}
- double vsqr(double u, double s){ return SQ(u) + 2.0 * a * s;}
- void solve(int side, double distance, double length, double angle, double u){
- if(side==0){
- if(abs(ar[1]-ar[2])<=eps){
- double hyp = otibhuj(ar[1], ar[1]);
- double vsq = vsqr(u, hyp);
- if(vsq<0) return;
- hor++, ver++;
- solve(0, 0, 0, 45, sqrt(vsq));
- }
- else if(ar[1]>ar[2]){
- double l = lombo(ar[2], angle);
- double hyp = otibhuj(ar[2], l);
- double vsq = vsqr(u, hyp);
- if(vsq<0) return;
- hor++;
- solve(1, ar[1]-l, ar[2], angle, sqrt(vsq));
- }
- else{
- double l = lombo(ar[1], angle);
- double hyp = otibhuj(ar[1], l);
- double vsq = vsqr(u, hyp);
- if(vsq<0) return;
- ver++;
- solve(2, ar[2]-l, ar[1], angle, sqrt(vsq));
- }
- }
- else{
- double l1 = lombo(distance, angle);
- double l2 = lombo(length, 90.0-angle);
- double hyp = otibhuj(distance, l1);
- double vsq = vsqr(u, hyp);
- // cout<<side<<' '<<l1<<' '<<l2<<'\n';
- if(l1<=length && l2<=distance){
- if(vsq<0) return;
- hor++; ver++;
- solve(0, 0, 0, 45, sqrt(vsq));
- }
- else if(l1<length){
- if(vsq<0) return;
- distance = length - l1;
- if(side==1){
- side=2;
- length = ar[1];
- ver++;
- }
- else{
- side=1;
- length = ar[2];
- hor++;
- }
- solve(side, distance, length, 90.0 - angle, sqrt(vsq));
- }
- else if(l2<distance){
- hyp = otibhuj(length, l2);
- vsq = vsqr(u, hyp);
- if(vsq<0) return;
- // cout<<"hello "<<vsq<<'\n';
- distance = distance - l2;
- if(side==1) hor++;
- else ver++;
- solve(side, distance, length, angle, sqrt(vsq));
- }
- }
- }
- int main(){
- #ifndef ONLINE_JUDGE
- clock_t tStart = clock();
- freopen("input.txt", "r", stdin);
- freopen("output.txt", "w", stdout);
- #endif
- double angle, vel, time;
- while(cin>>ar[1]>>ar[2]>>vel>>angle>>time){
- if(abs(ar[1]-ar[2]+vel-time)<=eps) break;
- swap(ar[1], ar[2]);
- a = (-vel)/time;
- hor=0;
- ver=0;
- double distance = ar[2]/2.0;
- double length = ar[1]/2.0;
- double l1 = lombo(distance, angle);
- double l2 = lombo(length, 90.0-angle);
- double hyp = otibhuj(distance, l1);
- double hyp2 = otibhuj(length, l2);
- double vsq = vsqr(vel, hyp);
- double vsq2 = vsqr(vel, hyp2);
- if(l1<=length && l2<=distance && vsq>=0){
- hor++; ver++;
- solve(0, 0, 0, 45, sqrt(vsq));
- }
- else if(l1<=length && vsq>=0){
- distance = length - l1;
- length = ar[2];
- hor++;
- // cout<<"Hello "<<l1<<' '<<l2<<'\n';
- solve(1, distance, length, 90.0 - angle, sqrt(vsq));
- }
- else if(l2<=distance && vsq2>=0){
- distance = distance - l2;
- length = ar[1];
- ver++;
- solve(2, distance, length, angle, sqrt(vsq2));
- }
- pf2(hor, ver); line;
- }
- #ifndef ONLINE_JUDGE
- fprintf(stderr, "\n>> Runtime: %.10fs\n", (double) (clock() - tStart) / CLOCKS_PER_SEC);
- #endif
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement