HDU 4873ZCC Loves Intersection
来源:互联网 发布:中世纪2mod原版优化9 编辑:程序博客网 时间:2024/06/05 17:28
After beats all opponents in 3-dimension-world OI, ZCC feels bored and sets about going to other universes. In a universe with D dimension(s), ZCC finds D segments floating in the air. To be more precise: if we build a rectangular coordinate system with D axis, each of the segments is parallel with one axis, whose endpoints have a coordination of which all components belong to the set {x∈Z|0≤x<N}. For each axis, there is exactly one segment parallel with it.
Each of the D segments changes location every second. Read the pseudo code below for more details:
Every second, from every pair of segments intersect, ZCC acquires a unit of Energy. Calculate the Expectation of the amount of the acquired energy per second please.
Each of the D segments changes location every second. Read the pseudo code below for more details:
Every second, from every pair of segments intersect, ZCC acquires a unit of Energy. Calculate the Expectation of the amount of the acquired energy per second please.
Every test case contain two positive numbers N, D in one line.
It is guaranteed that 1<N≤10^9, D≤99. The number of test cases≤10.
2 23 35 5
149/8118/625问一个d维空间里,d条分别平行于d维的随机线段相交的期望。
首先,任意两条线段相交的几率是相同的,所以答案是C(d,2)*任意两条线段相交的概率
两条线段要相交,那么出去平行的两维以外,其他维度必须相同,那么概率是1/n^(d-2)
然后考虑平面上两条平行于x轴和y轴的随机线段相交的概率。
假设两条线段长度分别为i和j,相交的全部情况为
∑∑n*(n-i)(长度为i的条数)*n*(n-j)(长度为j的条数)*i/n*j/n(相交的前提)
除于全部的情况,(n*n*(n-1)/2)^2
然后就是喜闻乐见的化简过程,最后答案就是 d(d-1)(n+4)^2/18n^d
显然答案可能很大,所以上个java大数就ok了。
import java.math.BigInteger;import java.util.Scanner;public class Main {public static void main(String[] args){Scanner in=new Scanner(System.in);while (in.hasNext()){BigInteger n = in.nextBigInteger();BigInteger d = in.nextBigInteger();BigInteger x = d.multiply(d.subtract(BigInteger.ONE));x = x.multiply(n.add(BigInteger.valueOf(4)));x = x.multiply(n.add(BigInteger.valueOf(4)));BigInteger y = BigInteger.valueOf(18);for (int i=1;i<=d.intValue();i++) y = y.multiply(n);System.out.println(x.divide(x.gcd(y))+"/"+y.divide(y.gcd(x)));}in.close();}}
0 0
- HDU 4873ZCC Loves Intersection
- 【HDU】4873 ZCC Loves Intersection 数学
- hdu 4873 ZCC Loves Intersection(大数+概率)
- HDU 4873 ZCC Loves Intersection(概率)
- hdu 4873 ZCC Loves Intersection 概率推导 java大整数
- BZOJ3841: ZCC Loves Intersection
- 【2014 Multi-University Training Contest 2 1002】/【HDU 4873】 ZCC Loves Intersection
- hdu 4882 ZCC Loves Codefires
- hdu 4882ZCC Loves Codefires
- HDU 4876 ZCC loves cards
- HDU-4876-ZCC loves cards
- hdu 4879 ZCC loves march
- hdu 4876 ZCC loves cards
- HDU 5229 ZCC loves strings
- hdu 5299 ZCC loves strings
- hdu 5229 ZCC loves strings
- hdu 5230 ZCC loves hacking
- hdu 5229 ZCC loves strings
- Java的锁机制
- 生物信息学习——tophat运行报错
- 死锁的四个条件
- Springboot 整合 Dubbo/ZooKeeper 详解 SOA 案例
- Executor框架简介-java并发编程
- HDU 4873ZCC Loves Intersection
- node实验代码
- 垃圾回收器——新生代收集器
- myeclipse--常用快捷键
- 去除ci index.php
- cstring与string头文件与输出
- apt-cache命令的常规用法
- Andriod内存
- 我从1万小时编程中学到了什么