CSU1602: Needle Throwing Game(投针问题)
2015-05-03 19:46
162 查看
Description
There are many parallel lines on the ground with the distance of D between each adjacent two. Now, throwing a needle randomly on the ground,please calculate the possibility of that the needle can be across one of the lines.Input
The input consists of multiple test cases. Each test case contains 2 integers D, L on a single line (1 <= D, L <= 100). The input is ended with EOF.Output
For each test case, print an integer of (int)(P*10000) where P is the possibility asked above. For example, when P = 0.25658,you should output 2565.Sample Input
4 2 2 4
Sample Output
3183 8372
HINT
Source
裸的投针问题,不知道的童鞋可以自己百度,直接公式。。。对于这种公式题,知道公式与不知道的差别瞬间就体现出来了
#include <iostream> #include <stdio.h> #include <string.h> #include <stack> #include <queue> #include <map> #include <set> #include <vector> #include <math.h> #include <algorithm> using namespace std; #define ls 2*i #define rs 2*i+1 #define up(i,x,y) for(i=x;i<=y;i++) #define down(i,x,y) for(i=x;i>=y;i--) #define mem(a,x) memset(a,x,sizeof(a)) #define w(a) while(a) #define LL long long const double PI = acos(-1.0); #define Len 200005 #define mod 19999997 const int INF = 0x3f3f3f3f; #define exp 1e-8 int main() { double L,D; double P; w(~scanf("%lf%lf",&D,&L)) { if(L<D) P=2*L/(PI*D); else P=1+(2.0/PI)*((L*1.0/D)*(1-sqrt((1-(D*D)/(L*L))))-asin(D*1.0/L)); P=P*10000; printf("%d\n",(int)P); } return 0; }
相关文章推荐
- CSU 1602 Needle Throwing Game (投针问题)
- [K倍动态减法问题] HDU 2486 & HDU2580 & POJ3922 a simple stone game
- BZOJ1775: [Usaco2009 Dec]Vidgame 电视游戏问题
- hdu 1564 Play a game 巴什博弈/棋盘博弈问题
- 文章标题CSU 1862: The Same Game(模拟)
- HDU 5643 King's Game (约瑟夫环问题的变形 递推)
- CSU 1809 括号匹配问题
- CSU 1160(进制问题)
- Bzoj1775 [Usaco2009 Dec]Vidgame 电视游戏问题
- 2-SAT 问题回顾(CSU 1844)
- U3D NGUI改变GameObject Activity闪烁的问题
- CSU 1256 天朝的单行道 最短路问题
- CSU 1592 石子归并 相邻操作Dp问题
- 虚幻4UI和游戏Game切换的时候,鼠标的隐藏和显示需要多点一下问题的解决方法
- 关于老古董1602黑块的问题....
- 三种经典博弈问题 BashGame;WythoffGame;NimmGame;
- VS2005+DirectX 9平台配置出现的问题以及解决方案--Game Scripting Mastery
- 把gameobject拖进prefab的问题【Untiy3D】
- 关于Unity GameObject.Find()、transform.Find()、transform.GetChild()的效率问题
- 哈理工OJ 2033 A Funny Game(博弈问题)