The third Blue Bridge Cup Javac Group _ put wheat

Source: Internet
Author: User

/* (Start of program header comment)

* Copyright and version Declaration section of the program

* Copyright (c) 2016, Guangzhou Science and Technology Trade Vocational College, Department of Information Engineering students

* All rights reserved.

* File name: Blue Bridge Cup title

* Author: Pengjunhau

* Completion Date: April 01, 2016

* Version number: 001

* Description part of task and solution method

* Input Description: None

* Description of the problem:

You must have heard the story. The King admired the minister who invented chess and asked him what he wanted to pay,
The minister said, "Please put 1 grains of wheat in the 1th checkerboard, 2 grains of wheat in the 2nd checkerboard, and 4 tablets in the 3rd checkerboard."
Wheat, put 8 grains of wheat in the 4th checkerboard, ... The number in the last lattice is twice times the previous one, until all
Checkerboard (64 chess in total).

The King thought he just wanted a sack of wheat and laughed.

It was impossible to calculate accurately at that time, but the results were surprising: even the whole world was full of wheat!

Please calculate exactly how many grains of wheat you need by computer.

* Program output: None

* End of comment on the program head

*/

On the code:

Import Java.math.BigInteger;

public class Main {

public static void Main (string[] args) {
BigInteger B1 = new BigInteger ("1");
for (int i = 1; i <=; i++) {
B1 = B1.multiply (biginteger.valueof (2));
}
B1 = B1.subtract (Biginteger.one);
System.out.println (B1);
}

}

The third Blue Bridge Cup Javac Group _ wheat

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.