hdu 5142 NPY and FFT(水)

 

http://acm.hdu.edu.cn/showproblem.php?pid=5142

#include<cstdio>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int bin[100];
int main()
{
    int t,n,i,j,k;
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d",&n);
        memset(bin,0,sizeof(bin));
        int coun=0;
        while(n)
        {
            bin[coun++]=n%2;
            n/=2;
        }
        while(bin[coun]==0) coun--;
        int ans=0;
        int wei=0;
        for(i=coun;i>=0;i--)
        {
            int temp=bin[i]*(int)pow(2,wei++);
            ans+=temp;
            //printf("%d...\n",temp);
        }
        printf("%d\n",ans);
    }
    return 0;
}
View Code

 

posted @ 2015-01-25 17:24  sola94  阅读(153)  评论(0编辑  收藏  举报