poj_1068 Parencodings

#include <stdio.h>
typedef  unsigned int U32;
int main(void)
{
    U32 t;
    U32 n;
    U32 j;
    char i;
    char p=0;
    U32 a;
    scanf("%u",&t);
    if(t>10)
        return;
    while(t--)
    {
        scanf("%u",&n);
        if(n>20)
        return;
        a |= ~0;
        for(i=0;i<n;i++)
        {
            scanf("%u",&j);
            for(j-=1;j>=0;j--)
            {
                p++;	
                if((a>>j&0x01) == 1)
                {
                    a &= ~(0x01<<j);
                	break;
                }
            }
            printf("%u ",p);
            p=0;
        }
        printf("\n");
    }
}

猜你喜欢

转载自blog.csdn.net/zhenglie110/article/details/43759449