题目连接

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. EXT学习之——Extjs 文本框 TextField 添加点击(onclick)事件方法

    { xtype:'textfield', listeners: { render: function(p) { // Append the Panel to the click handler's a ...

  2. ASPxGridView的自动排序(写在onCustomUnboundColumnData()事件中)

    //此排序写于后台,可打印出序号 protected void ASPxGridView_progoods_CustomUnboundColumnData(object sender, DevExpr ...

  3. jQuery 监控键盘一段时间内没输入

    监控一段时间没输入可用于简单的输入完成 上次实现了一个模拟输入完成则发送请求到后台获取数据的并显示到前台的问题,其中核心的判断标准是输入完成的定义. 即:用户怎么算输入完成. 我使用的标准是,当一个文 ...

  4. JS与JQ倒计时的写法

    页面需要制作一个倒计时的功能:然后度娘了一遍,找到两种写法,原生JS与JQ 的,经过测试原生JS在IE可能会有不刷新的现象所以结合了一个大神的JQ写法修改好了一个. 原生JS写法: HTML: < ...

  5. 【Python】django模型models的外键关联使用

    Python 2.7.10,django 1.8.6 外键关联:http://www.bubuko.com/infodetail-618303.html 字段属性:http://www.cnblogs ...

  6. 使用Git上传本地项目代码到github

    前提:(1)ssh密钥(让本地与git链接) &  (2)装好gitbash 1.git中创建好库 2.文件夹中输入:git init (出现隐藏的.git文件) 3.git remote a ...

  7. jQuery 遍历 - map() 方法

    定义和用法 map() 把每个元素通过函数传递到当前匹配集合中,生成包含返回值的新的 jQuery 对象. 例子1: 构建表单中所有值的列表: <p><b>value为: &l ...

  8. HttpClient入门

    HttpClient入门 HttpClient 是 Apache Jakarta Common 下的子项目,可以用来提供高效的.最新的.功能丰富的支持 HTTP 协议的客户端编程工具包,并且它支持 H ...

  9. xcode不能连接svn以及不能导入的解决方法

    配置svn的方法不多说,网上一堆.这里要说的是怎么解决连接不上svn以及在xcode中不能修改svn目录的问题.   首先,xcode连接不上linux的svn,一般来说,问题就出在端口上.svn的默 ...

  10. js 实现获取对象所有键名(key)的方法

    1.for in 循环 并且使用hasOwnProperty 方法 var jsonObject1 = { "name": "xiaoming", " ...