The 50-power algorithm of C ++ 2

Source: Internet
Author: User

I did not know how to solve this problem when I participated in the ACM competition last year. I finally solved it today. It was so simple that I only needed _ int64


# Include <iostream>

Using STD: cout;
Using STD: Endl;
Int main ()
_ Int64 sum = 0, multiply = 1;

For (INT I = 1; I! = 50; ++ I)
Multiply * = 2;
Sum + = multiply;
Cout <sum <Endl;
Return 0;


_ Int64


This is explained in msdn.

_ Int64 nhuge; // declares 64-bit integer

Declare a 64-bit integer, that is, its range is between +-(63 power-1 of 2), so the problem is solved naturally.


The running result is as follows:



Related Article

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: 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.