CSU1602: Needle Throwing Game)

Source: Internet
Author: User

CSU1602: Needle Throwing Game)
Description

There are using 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 needle can be attached SS 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 shoshould output 2565.

 

Sample Input
4 22 4
Sample Output
31838372
HINT

 

Source
Bare needle injection problem, do not know the children's shoes can Baidu, directly formula... For such a formula question, knowing the difference between the formula and the unknown is instantly reflected.
#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 longconst double PI = acos(-1.0);#define Len 200005#define mod 19999997const int INF = 0x3f3f3f3f;#define exp 1e-8int main(){ double L,D; double P; w(~scanf("%lf%lf",&D,&L)) { if(L
          
         
        
       
     
    
   
  
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.