题目连接

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

NPY and FFT

Description

A boy named NPY is learning FFT algorithm now.In that algorithm,he needs to do an operation called "reverse".
For example,if the given number is 10.Its binary representaion is 1010.After reversing,the binary number will be 0101.And then we should ignore the leading zero.Then the number we get will be 5,whose binary representaion is 101.
NPY is very interested in this operation.For every given number,he want to know what number he will get after reversing.Can you help him?

Input

The first line contains a integer T — the number of queries $(1 \leq T \leq 100).$
The next T lines,each contains a integer $\begin{align*}X(0 \leq X \leq 2^{31}-1)\end{align*}$,the given number.

Output

For each query,print the reversed number in a separate line.

Sample Input

3
6
8
1

Sample Output

3
1
1

想用位运算写,结果写不来只好用笨办法写了。。

 #include<cstring>
#include<cstdio>
int buf[];
void go(int n) {
int i, j = , res = ;
memset(buf, , sizeof(buf));
do buf[j++] = n & ; while (n >>= );
for (i = j - ; ~i; i--) res += buf[i] * ( << (j - i - ));
printf("%d\n", res);
}
int main() {
int t, n;
scanf("%d", &t);
while (t--) scanf("%d", &n), go(n);
return ;
}

hdu 5142 NPY and FFT的更多相关文章

  1. hdu 5142(数学-进制转换)

    NPY and FFT Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total ...

  2. HDU 4609 3-idiots(FFT)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4609 题意:给出n个正整数(数组A).每次随机选出三个数.问这三个数能组成三角形的概率为多大? 思路: ...

  3. HDU 5144 NPY and shot(物理运动学+三分查找)

    NPY and shot Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Tot ...

  4. hdu 5144 NPY and shot 物理+三分

    NPY and shot Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Pro ...

  5. HDU 5145 NPY and girls 莫队+逆元

    NPY and girls Problem Description NPY's girlfriend blew him out!His honey doesn't love him any more! ...

  6. hdu 5144 NPY and shot

    http://acm.hdu.edu.cn/showproblem.php?pid=5144 题意:给你初始的高度和速度,然后让你求出水平的最远距离. 思路:三分枚举角度,然后根据公式求出水平距离. ...

  7. hdu 5730 Shell Necklace fft+cdq分治

    题目链接 dp[n] = sigma(a[i]*dp[n-i]), 给出a1.....an, 求dp[n]. n为1e5. 这个式子的形式显然是一个卷积, 所以可以用fft来优化一下, 但是这样也是会 ...

  8. HDU 5145 NPY and girls(莫队算法+乘法逆元)

    [题目链接] http://acm.hdu.edu.cn/showproblem.php?pid=5145 [题目大意] 给出一个数列,每次求一个区间数字的非重排列数量.答案对1e9+7取模. [题解 ...

  9. HDU 4609 3-idiots (组合数学 + FFT)

    题意:给定 n 条边,问随机选出 3 条边,能组成三角形的概率是多少. 析:答案很明显就是  能组成三角形的种数 / (C(n, 3)).现在的问题是怎么求能组成三角形的种数. 这个博客说的非常清楚了 ...

随机推荐

  1. 区间k大数查询

    问题描述 给定一个序列,每次询问序列中第l个数到第r个数中第K大的数是哪个. 输入格式 第一行包含一个数n,表示序列长度. 第二行包含n个正整数,表示给定的序列. 第三个包含一个正整数m,表示询问个数 ...

  2. 简单的TCPIP 客户端 服务器

    // soClient.cpp : Defines the entry point for the console application. // #include "stdafx.h&qu ...

  3. ios开发经典语录锦集

    原文链接: iPhone开发经典语录集锦 前言:iPhone是个极具艺术性的平台,相信大家在开发过程中一定有很多感触,希望能写出来一起交流,所以开了这个帖子,以后还会维护. 如果大家和我一样有感触的话 ...

  4. hbase日常运维管用命令,region管理

    1         Hbase日常运维 1.1       监控Hbase运行状况 1.1.1        操作系统 1.1.1.1 IO 群集网络IO,磁盘IO,HDFS IO IO越大说明文件读 ...

  5. hdu2571

    if(x==1) f(x,y)=max{f(x,y-1),f(x,z)}  {y%z==0&&1<y/z<=y&&1<=z<<y} els ...

  6. JSON对象遍历方法

    JSON对象提前不知道其属性和结构,遍历其值 var json2 = { "name": "txt1", "name2": "tx ...

  7. JDBC数据库连接(MySQL为例)

    1.什么是JDBC?有什么作用? Java Data Base Connectivity  Java数据库连接协议 是一种用于执行SQL语句的Java API,可以为多种关系数据库提供统一访问. 他提 ...

  8. [原]sdut2605 A^X mod P 山东省第四届ACM省赛(打表,快速幂模思想,哈希)

    本文出自:http://blog.csdn.net/svitter 题意: f(x) = K, x = 1 f(x) = (a*f(x-1) + b)%m , x > 1 求出( A^(f(1) ...

  9. javascript中for/in循环及使用技巧

    JavaScript 支持不同类型的循环: for - 循环代码块一定的次数 for/in - 循环遍历对象的属性 while - 当指定的条件为 true 时循环指定的代码块 do/while - ...

  10. C语言中的关键字

    1.C语言中的关键字都有实际的意义. 2.C语言中的23个关键字如下: char:声明字符型变量. short:声明短整型变量. int:声明整型变量. long:声明长整型变量. float:声明浮 ...