Miscalculation problem (i)

Source: Internet
Author: User

1: Questions raised

Legend has it that the popular chess is the ancient king of Daye invented in the thinking. Shehan very fond of chess, decided to let the Prime Minister himself request what reward. The wise Prime Minister pointed to 8x8 a total of 64 chess disc, said: "Your Majesty, favor give me some wheat bar, on the board of the 1th grid 1 tablets, 2nd Geffon 2, 3rd Geffon 4 tablets, after each lattice is more than the previous one, and then put the board on the 64 grid, I am grateful for the endless."

Shehan to carry a sack of wheat, he will fulfill his promise.

May I ask the King to honor his promise? How much wheat is there to reward his Prime minister? How many cubic meters (1 cubic meters of wheat 1.42e8 grains)? If they were piled up in a cone-shaped pile of wheat, how high was the heap of wheat?

2: Analysis

1th Block 1, 2nd Block 2, 3rd Block 4, 4th lattice 8, 5th 16, total number of grains should be:

Total number of grains = 1 + 2 + 2 (2) + 2 (3) + 2 (4) + ... + 2 (63) [Where 2 (2) means 2 of 2 times]

After calculating the total grain count of the wheat, the rest is fine.

3: Program Implementation

#include <stdio.h> #include <stdlib.h> #include <math.h> #define N1.42e8#define PI3.1415926/** * king's miscalculation * *intMain () {Doublet =1;/ * Indicates the first 1 grain m * /    Doubles =1;/ * Indicates the total number of grains of rice * /    intn =1;/ * denotes nth lattice * /    intSize =1;DoubleV/ * Square number * /    DoubleH/ * Height * /printf"Please enter total number of cells: \ n"); scanf"%d", &size); for(n =1; n < size; n++) {t = T *2;    s = s + t; } printf ("Total number of grains:%.3e tablets \ n", s);    v = S/n; printf"equivalent Volume:%.0f cubic meter \ n", v);/** is calculated from the volume of the cone to V = 1/3*s*h **/    DoubleH2 = v *9/PI; h = Pow (H2,1.0/3); printf"The height of the positive cone is:%.0f m \ n", h);return 0;}

4: Program Results

Miscalculation problem (i)

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.