UVa 11971 (probability) Polygon

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.