The violent calculation of the choice question of 12 questions in the college entrance examination in 2017

Source: Internet
Author: User

It is clear that if the candidate's words should be a regular or to push out a formula calculation
Here we use brute force computation to solve, it is very straightforward to find out the first 500 items, and their and, and then judge can

The code is as follows:

#include <cstdio>
#include <cmath>
using namespace std;
const int MAX = 1E5;
int A[max];
int main (void) {
    int Count = 0;
    A[1] = 1;a[2] = 1;
    int sum = 0;
    for (int i=0;i<=450;i+=count) {
        count++;
        for (int j=1;j<=count;j++) {
            a[i+j] = POW (2,j-1);//Here is the solution
            for each sum = = a[i+j];//take their and compute out
        /    printf ("%d%d%lld\n", i+j,a[i+j],sum);
            if (Sum & (sum-1) = = 0)//This is used to determine that sum conforms to the power of a mismatch of 2, and here you can add a i+j>100 directly to find the result
            {
                printf ("%d and%d\n", i+j , sum);
    }} return 0;
}

So what we get is an item that matches the top N and the power of 2, and the result is as follows:

Obviously n>100 so it should be 440, so choose a. ~ ~ Of course, the college entrance examination can not take the computer, ...

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.