首页 > 代码库 > hdu 5142 NPY and FFT(水)

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

 

hdu 5142 NPY and FFT(水)