Ultraviolet A 474-heads/tails Probability

Source: Internet
Author: User

Question: The first 4 of the values of 1/(2 ^ N) is the valid number and number of digits.

Analysis: number theory, big integer. Directly simulate it with arrays.

Description: Performs table computing and queries and outputs.

# Include <iostream> # include <cstdlib> # include <cstdio> # include <cmath> using namespace STD; double Val [1000005]; int bit [1000005]; int main () {Val [0] = 1; bit [0] = 0; For (INT I = 1; I <1000001; ++ I) {Val [I] = Val [I-1]/2; bit [I] = B [I-1]; If (Val [I] <1) {Val [I] * = 10; bit [I] -- ;}} int N; while (~ Scanf ("% d", & N) printf ("2 ^-% d = %. 3lfe % d \ n ", N, Val [N], bit [N]); Return 0 ;}

Ultraviolet A 474-heads/tails Probability

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.