您的位置:首页 > 其它

hdu 5142 NPY and FFT

2015-06-08 18:07 183 查看
原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=5142

[code]#include<cstring>
#include<cstdio>
#include<cmath>
int buf[40];
void go(int n) {
    int i, j = 0, res = 0;
    memset(buf, 0, sizeof(buf));
    do buf[j++] = n % 2; while (n /= 2);
    for (i = j - 1; ~i; i--) res += buf[i] * (int)pow(2, j - i - 1);
    printf("%d\n", res);
}
int main() {
    int t, n;
    scanf("%d", &t);
    while (t--) scanf("%d", &n), go(n);
    return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: