zju1359 这题什么意思啊

来源:百度知道 编辑:UC知道 时间:2024/05/24 12:43:43
Out of N soldiers, standing in one line, it is required to choose several to send them scouting.
In order to do that, the following operation is performed several times: if the line consists of more than three soldiers, then all soldiers, standing on even positions, or all soldiers, standing on odd positions, are taken away. The above is done until three or less soldiers are left in the line. They are sent scouting. Find, how many different groups of three scouts may be created this way.

Note: Groups with less than three number of soldiers are not taken into consideration.

0 < N <= 10 000 000

#include"stdio.h"
#include"math.h"
void main()
{
int a[10]={0},n,i=0,l,s=0;
puts("ENTER SOLIDIERS NUMBER");
while((scanf("%d",&n))!=EOF)
{
for(;n>=6;)
{
if(n%2==0)
n/=2;
else
n=(n-1)/2;
i++;
}
for(l=0;l<n;l++)
{
s+=pow(2,i);
a[l]=s;
}
for(n-=3,l=0;n>0;n--,l++)
a[2*l]=0;
for(l=0,i=0;i<3;l++)
{
if(l>5)
break;
if(a[l]==0)
continue;
else
{
printf("%d\t",a[l]);
i++;
}
}
printf("\n");
for(i=0;i<10;i++)
a[i]=0;
i=s=0;
}
}

#include"stdio.h"
#include"stdlib.h"
typedef struct MONKEY
{
int n;
struct MONKEY* next;
}monkey;
void main(