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.