Computer College Undergraduate Program Design contest (2015 ' 11) 1001 Moving Bricks

Source: Internet
Author: User
Tags ming first row
1001 Moving Bricks Time limit:2000/1000 MS (java/others) Memory limit:65535/65535 K (java/others)
Problem Description Xiao Ming is now a person to see love, flowers and flowers to open the Gaofu, all day immersed in beauty surrounded by the dance of the wonderful. But people do not know, the brilliance of Xiaoming has also had a hard struggle history.

At that time Xiao Ming has not cut long hair, no credit card without her, no 24 hours of hot water home, but the original xiaoming is so happy, although not even a broken wood guitar ...

The reason is happy, because then Xiao Ming with the dream of reverse attack. One day, xiaoming to the goddess of his mind to buy a birthday gift, came to a construction site to move bricks for money. At this time, there was a truck of bricks on the construction site, and the contractor Jean Xiaoming the pile of bricks from the truck and divided it into pieces (requiring any 2 turns to be separated). As a senior porter, Xiaoming always divides a pile of bricks into two piles, at this time, the energy consumed is divided into two piles of bricks after the number of difference.

Now, the number of bricks known to come from trucks, please tell xiaoming at least how much physical strength to complete the task required by the contractor.

Input input data The first row is a positive integer t (t<=100), which indicates that there is a T-group test data.
The next T line is a positive integer N (n<=10000000) per line that represents the number of bricks the truck is carrying.
Output for each set of data, export the minimum amount of physical energy required by xiaoming to complete the task.
Sample Input
2 4 5
Sample Output
1 S

#include <stdio.h>
#include <stdlib.h>
int f;
void Jieguo (int n)
{
        int a,b;
    if (n==1| | n==2) return;
    A=N/2;
    B=N/2;
    if (a+b!=n)
    {
        f++;
        a++;
    }
        Jieguo (a);
        Jieguo (b);
}
void Fendui (int n)
{
    f=0;
    int a,b;
    if (n==1| | n==2) goto end;
    A=N/2;
    B=N/2;
    if (a+b!=n)
    {
        f++;
        a++;
    }
        Jieguo (a);
        Jieguo (b);
        end:printf ("%d\n", f);
}
int main ()
{
    int i,n,t;
    scanf ("%d", &t);
    for (i=1;i<=t;i++)
    {
        scanf ("%d", &n);
        Fendui (n);
    }
    return 0;
}

Always looking at once space daze, those who say not separate friends, turn around, strangers. Familiar, quiet, quiet, left, left, unfamiliar, unfamiliar, disappeared, disappeared, strangers.

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