Choose and divide UVA - 10375
待理解,待重做
1 #include<cstdio> 2 #include<cstring> 3 #include<iostream> 4 #include<algorithm> 5 using namespace std; 6 typedef long long ll; 7 8 int main() 9 { int p,q,r,s; 10 while(~scanf("%d%d%d%d",&p,&q,&r,&s)){ 11 double ans=1.0; 12 if(p-q<q) q=p-q; 13 if(r-s<s) s=r-s; 14 for(int i=1;i<=q||i<=s;i++){ 15 if(i<=q) ans=ans*(p-q+i)/i; 16 if(i<=s) ans=ans/(r-s+i)*i; 17 } 18 printf("%.5f\n",ans); 19 } 20 return 0; 21 }