Test instructions
There is a rope, the above randomly selected K tangent point, cut it into k+1 section, to find the probability of these segments can be k+1 edge shape.
Analysis:
To form a k+1 edge, the longest segment must be smaller than the sum of the other K segments.
Purple Book gives a solution, but feel not too good to understand, so went to the Internet to find other solutions.
The question has been asked, and a number of rigorous solutions have been given.
The final code will be (1LL << i) written in (1 << i), this detail should be noted.
1#include <cstdio>2typedefLong Longll;3 4 ll GCD (ll A, ll b)5 {6 if(b = =0)returnA;7 returnGCD (b, a%b);8 }9 Ten Const intMAXN = -; Onell A[MAXN +5], B[MAXN +5]; A - voidinit_table () - { theb[1] =1; - for(inti =2; I <= MAXN; ++i) - { - ll G; +B[i] = 1ll <<i; -A[i] = b[i]-I-1; +g =gcd (A[i], b[i]); AA[i]/= G, B[i]/=G; at } - } - - intMain () - { - init_table (); in intT; -scanf"%d", &t); to for(intKase =1; Kase <= t; ++Kase) + { - intK; thescanf"%d", &k); *scanf"%d", &k); $printf"Case #%d:%lld/%lld\n", Kase, A[k], b[k]);Panax Notoginseng } - the return 0; +}code June
UVa 11971 (probability) Polygon