UVA - 10375 Choose and divide

来源:互联网 发布:java最新版qq下载 编辑:程序博客网 时间:2024/05/17 16:15



显然我这不是正解,充分利用了long double,没想到还能过。


#include<cstdio>#include<string>#include<cstring>#include<iostream>#include<cmath>#include<algorithm>#include<iomanip>using namespace std;typedef long long ll;const int INF =0x3f3f3f3f;int p,q,r,s;//ans=C(p,q)/C(r,s);long double C(int x,int y){    y=min(x-y,y);    long double ans=1;    for(int i=1;i<=y;i++)    {        ans=ans*(x-i+1)/i;    }    return ans;}long double work(){    return C(p,q)/C(r,s);}int main(){    while(~scanf("%d%d%d%d",&p,&q,&r,&s))    {          cout<<fixed<<setprecision(5)<<work()<<endl;    }   return 0;}


0 0
原创粉丝点击