najimCseJu

Problem - A ( uva 11130 - Billiard bounces)

Jul 9th, 2014
341
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.05 KB | None | 0 0
  1. #include<algorithm>
  2. #include<bitset>
  3. #include<cctype>
  4. #include<math.h>
  5. #include<stdio.h>
  6. #include<stdlib.h>
  7. #include<string.h>
  8. #include<iostream>
  9. #include<iterator>
  10. #include<map>
  11. #include<queue>
  12. #include<set>
  13. #include<sstream>
  14. #include<stack>
  15. #include<strstream>
  16. #include<string>
  17. #include<utility>
  18. #include<vector>
  19. #include <cstdarg>
  20. using namespace std;
  21. /***************************************************************************************************************************************/
  22. typedef long long int LLI;
  23. typedef unsigned long long int ULLI;
  24. #define MP(X,Y) make_pair(X,Y)
  25.  
  26. #define REP(i,n) for(int i=0;i<n;i++)
  27. #define FOR(i,a,b) for(int i=a;i<=b;i++)
  28.  
  29. #define fill(a,v) memset(a,v,sizeof(a))
  30. #define fillx(a,v,n) memset(a,v,n*sizeof(a[0]))
  31. #define DEBUG(x) cout << #x << ": " << x << endl;
  32. #define all(x) (x).begin(),(x).end()
  33. #define SORT(x) sort(all(x))
  34. #define VI vector<int>
  35. #define VS vector<string>
  36. #define PB push_back
  37. #define REV(a) reverse(all(a))
  38. typedef pair<int, int>PII;
  39.  
  40. template<class T> inline T MIN_3(T a, T b, T c)
  41. {
  42. return min(min(a, b), c);
  43. }
  44.  
  45.  
  46. template<class T> inline T MAX_3(T a, T b, T c)
  47. {
  48. return max(max(a, b), c);
  49. }
  50.  
  51. #define BRPS(n,bit) bitset<bit>(n)
  52. #define LB(A, x) (lower_bound(all(A), x) - A.begin())//exactly where it starts
  53. #define UB(A, x) (upper_bound(all(A), x) - A.begin())
  54. #define UNQ(x) SORT(x),(x).erase(unique(all(x)),x.end())
  55.  
  56. template<class T> inline T BIGMOD(T n, T m, T mod)
  57. {
  58. LLI ans = 1;
  59. LLI k = n;
  60. while(m)
  61. {
  62. if(m & 1)
  63. {
  64. ans *= k;
  65. if(ans>mod) ans %= mod;
  66. }
  67. k *= k;
  68. if(k>mod) k %= mod;
  69. m >>= 1;
  70. }
  71. return ans;
  72. }
  73. #define eps 1e-11
  74. template<class T> string toString(T n)
  75. {
  76. ostringstream ost;
  77. ost << n;
  78. ost.flush();
  79. return ost.str();
  80. }
  81. template<class T> string toBinary(T n)
  82. {
  83. string ret="";
  84. while(n)
  85. {
  86. if(n%2==1)ret+='1';
  87. else ret+='0';
  88. n>>=1;
  89. }
  90. reverse(ret.begin(),ret.end());
  91. return ret;
  92. }
  93. void combination(int n,vector< vector<int> > &ret)
  94. {
  95. ret.resize(n+1, vector<int>(n+1, 0));
  96. for(int i=1; i<=n; i++)
  97. {
  98. ret[i][0]=ret[i][i]=1;
  99. for(int j=1; j<i; j++)
  100. {
  101. ret[i][j]=ret[i-1][j]+ret[i-1][j-1];
  102. }
  103. }
  104. }
  105. int toInt(string s)
  106. {
  107. int r = 0;
  108. istringstream sin(s);
  109. sin >> r;
  110. return r;
  111. }
  112. LLI toLInt(string s)
  113. {
  114. LLI r = 0;
  115. istringstream sin(s);
  116. sin >> r;
  117. return r;
  118. }
  119. double toDouble(string s)
  120. {
  121. double r = 0;
  122. istringstream sin(s);
  123. sin >> r;
  124. return r;
  125. }
  126. vector<string> parse(string temp)
  127. {
  128. vector<string> ans;
  129. ans.clear();
  130. string s;
  131. istringstream iss(temp);
  132. while (iss >> s)ans.PB(s);
  133. return ans;
  134. }
  135. template<class T> inline T gcd(T a, T b)
  136. {
  137. if (a < 0)return gcd(-a, b);
  138. if (b < 0)return gcd(a, -b);
  139. return (b == 0) ? a : gcd(b, a % b);
  140. }
  141. template<class T> inline T lcm(T a, T b)
  142. {
  143. if (a < 0)return lcm(-a, b);
  144. if (b < 0)return lcm(a, -b);
  145. return a*(b / gcd(a, b));
  146. }
  147. template<class T> inline T power(T b, T p)
  148. {
  149. if (p < 0)return -1;
  150. if (b <= 0)return -2;
  151. if (!p)return 1;
  152. return b*power(b, p - 1);
  153. }
  154.  
  155. template<class T> inline void asd(T &ret)
  156. {
  157. char r;
  158. bool start=false,neg=false;
  159. ret=0;
  160. while(true)
  161. {
  162. r=getchar();
  163. if((r-'0'<0 || r-'0'>9) && r!='-' && !start)
  164. {
  165. continue;
  166. }
  167. if((r-'0'<0 || r-'0'>9) && r!='-' && start)
  168. {
  169. break;
  170. }
  171. if(start)ret*=10;
  172. start=true;
  173. if(r=='-')neg=true;
  174. else ret+=r-'0';
  175. }
  176.  
  177. if(neg)
  178. ret*=-1;
  179. return ;
  180. }
  181.  
  182. template<class T> inline void asdasd(T x,char y)
  183. {
  184. // 0- print+newline, 1 - print ' ',2 - nothing;
  185. if (x < 0)
  186. {
  187. putchar('-');
  188. x = -x;
  189. }
  190. char buf[21], *p = buf;
  191. do
  192. {
  193. *p++ = '0' + x % 10;
  194. x /= 10;
  195. }
  196. while (x);
  197. do
  198. {
  199. putchar(*--p);
  200. }
  201. while (p > buf);
  202. if(y==0)putchar('\n');
  203. else if(y==1)putchar(' ');
  204. }
  205. #define filein(x) freopen(x,"r",stdin)
  206. #define fileout(x) freopen(x,"w",stdout)
  207. #define fst first
  208. #define snd second
  209. //istringstream(temp) >> data >> value >> stamp;
  210. //mod1 = 1000000007, mod2 = 1000000009;
  211. //.016-.040-.900-2.48
  212. /***************************************************************************************************************************************/
  213.  
  214. const double Pi=acos(-1.0);
  215. const double E=1e-9;
  216. double Rad(long long A)
  217. {
  218. return (Pi*A)/180.0;
  219. }
  220.  
  221. long long Ceil(double A)
  222. {
  223. return (long long)(A+.50);
  224. }
  225. int main()
  226. {
  227. long long a,b,v,A,s;
  228. while(cin >> a >> b >> v >> A >> s)
  229. {
  230. if(a==0 && b==0 && v==0 && A==0 && s==0)return 0;
  231. long long dis=(s*v)>>1;
  232. double X=dis*(cos(Rad(A)));
  233. double Y=dis*(sin(Rad(A)));
  234. cout << Ceil((X+E)/a) << " " << Ceil((Y+E)/b) << endl;
  235. }
  236.  
  237. return 0;
  238. }
Advertisement
Add Comment
Please, Sign In to add comment