题目连接

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. 【测试】trunc和round的区别

    trunc是截断:round是四舍五入:下面通过一个例子具体看一下trunc和round的不同 SQL),trunc() from dual; TRUNC() TRUNC() ------------ ...

  2. 关于BitmapFactory解析流的问题a

    今天碰到了一个超级恶心的问题,BitmapFactory.decodeStream(bis,null,options)一直是返回NULL 问题是这样子的: InputStream is= respon ...

  3. jsp-status 404错误的解决方法汇总

    接下来的解决方法实在一下情况下进行的: 1.tomcat配置是对的,能打开tomcat的主页(网址:http://localhost:8080/),如图, 但是在输入具体网址的时候,例如:http:/ ...

  4. Mybatis多条件查询

    在Mybatis多条件查询中: 1.参数如果是多条件,则需要将将添加到Map集合中进行传入. 2.就是将其参数用有序数字进行代替. Mybatis单个String类型参数传递 mysql文如下,传入参 ...

  5. Android IOS WebRTC 音视频开发总结(十一)-- stun&turn部署

    本篇文章主要介绍webrtc里面的stun,turn服务的安装与配置(转载请说明出处: http://www.cnblogs.com/lingyunhu, RTC.Blacker) 说到STUN,TU ...

  6. nginx安装详解

    一.环境: 1.Linux:centos6.4(32位) 2.Gcc的编译环境.使用make命令编辑. yum install gcc-c++ 3.PCRE PCRE(Perl Compatible ...

  7. rsync 安装与配置

    1.什么是rsync Rsync(remote synchronize)是一个远程数据同步工具,可通过LAN/WAN快速同步多台主机间的文件.Rsync使用所谓的“Rsync算法”来使本地和远 程两个 ...

  8. PHP中数据库的连接

    <?php //1.链接MySQL服务器 $conn = mysql_connect("localhost", "root" , 199452); //2 ...

  9. SQL中查看数据库各表的大小

    SQL中查看数据库各表的大小 编写人:CC阿爸 2014-6-17 在日常SQL数据库的操作中,如何快速的查询数据库中各表中数据的大小. 以下有两种方法供参考: 第一种: create table # ...

  10. 将List<T>转化成 DataTable--调整可空类型的转化错误

    加载表结构并保持成XML string cmdText = @"select * from kb_lable_temp where 1=2"; using (SqlConnecti ...