2698: 太阳轰炸
击中碎片的概率 p = ( R 1 + r ) 2 R 2 2 p = \frac {(R1+r)^2}{R2^2} p=R22(R1+r)2?
未击中的概率为 q = R 2 2 ? ( R 1 + r ) 2 R 2 2 q = \frac {R2^2-(R1+r)^2} {R2^2} q=R22R22?(R1+r)2?
摧毁碎片的概率
x = C ( n , k ) ? p k ? q n ? k + C ( n , k + 1 ) ? p k + 1 ? q n ? k ? 1 + … + C ( n , n ) ? p n ? q 0 x = C(n,k) * p^k * q^{n-k} + C(n,k+1) * p^{k+1} * q^{n-k-1} + … + C(n,n)*p^n*q^0 x=C(n,k)?pk?qn?k+C(n,k+1)?pk+1?qn?k?1+…+C(n,n)?pn?q0
#include<stdio.h>
const int N = 5000010, p = 1e9+7;
typedef long long LL;
LL fac[N],inv[N];
int ksm(int a,int b)
{
int res=1;for(;b;b>>=1){
if(b&1) res=(LL)res*a%p;a=(LL)a*a%p;}return res;
}
int C(int a,int b)
{
return fac[a]*inv[b]%p*inv[a-b]%p;
}
int main()
{
LL n,R1,R2,r,a,h,k;scanf("%lld%lld%lld%lld%lld%lld",&n,&R1,&R2,&r,&a,&h);if(h%a==0) k=h/a;else k=h/a+1;//上取整if(k>n)//k最大到n,>n时不可能,概率为0{
puts("0");return 0; }if(R2<=R1+r)//概率最大为1{
puts("1");return 0;}fac[0]=1;for(int i=1;i<=n+1;i++) fac[i]=fac[i-1]*i%p;//预处理出阶乘、阶乘的逆元inv[n+1]=ksm(fac[n+1],p-2);for(int i=n;i>=0;i--) inv[i]=inv[i+1]*(i+1)%p;int rn=ksm(R2*R2%p,p-2);//r2的逆元int pp=(R1+r)*(R1+r)%p*rn%p;//即概率pint qq=(R2*R2%p-(R1+r)*(R1+r)%p+p)%p*rn%p;//即概率qint pk=ksm(pp,k);//p^kint qnk=ksm(qq,n-k);//q^(n-k)LL res=0;for(int i=k;i<=n;i++){
res=res+(LL)C(n,i)*pk%p*qnk%p;res%=p;pk=(LL)pk*pp%p;qnk=(LL)qnk*ksm(qq,p-2)%p;}printf("%lld\n",res);return 0;
}