程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> C語言 >> C++ >> C++入門知識 >> CSU1602: Needle Throwing Game(投針問題)

CSU1602: Needle Throwing Game(投針問題)

編輯:C++入門知識

CSU1602: Needle Throwing Game(投針問題)


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 
#include 
#include 
#include 
#include 
#include
#include 
#include 
#include 
#include 
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





  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved