hdu 5142 NPY and FFT(二进制处理)
来源:互联网 发布:淘宝无线端链接地址 编辑:程序博客网 时间:2024/04/29 13:13
NPY and FFT
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 802 Accepted Submission(s): 493
Problem 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?
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≤T≤100 ).
The next T lines,each contains a integerX(0≤X≤231−1 ),the given number.
The next T lines,each contains a integer
Output
For each query,print the reversed number in a separate line.
Sample Input
3681
Sample Output
311
Source
BestCoder Round #22
题意:把n转换为二进制再翻转,去掉前导零后的数是多少思路:用数组保存二进制,处理前导零即可
代码:
#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>#include <cmath>using namespace std;int a[50],b[50];int main(){ int T,n; scanf("%d",&T); while(T--) { scanf("%d",&n); int cnt=0; while(n) { int t=n%2; a[cnt++]=t; n/=2; } int num; for(num=0; num<cnt; num++) if(a[num]) break; int tot=0; for(int i=cnt-1; i>=num; i--) b[tot++]=a[i]; int ans=0; for(int i=0; i<tot; i++) { if(b[i]) ans=ans+(1<<i); } printf("%d\n",ans); } return 0;}
0 0
- hdu 5142 NPY and FFT(二进制处理)
- HDU 5142 NPY and FFT 数的二进制倒转
- hdu 5142 NPY and FFT
- hdu 5142 NPY and FFT
- HDU-5142NPY and FFT
- HDU 5142 NPY and FFT(水~)
- HDOJ 5142 NPY and FFT
- HDOJ 5142 NPY and FFT 水
- 【CUGBACM15级BC第22场 A】hdu 5142 NPY and FFT
- Hdu 5145 NPY and girls
- HDU5142 NPY and FFT && BestCoder Round #22 1001
- hdu 5145 NPY and girls && 莫队算法 && 逆元处理
- 【HDU】5145 NPY and girls 【分块】
- HDU 5143 NPY and arithmetic progression DFS
- hdu 5143 NPY and arithmetic progression
- HDU 5143 NPY and arithmetic progression
- hdu 5143 NPY and arithmetic progression
- HDU 5144 NPY and shot (公式+三分)
- 赌场概率论
- TCP/IP协议栈的网络层的主要功能是通过( )来完成的。
- 数据结构——链表表的实现
- Docker中使用Python Notebook
- 绘制渐变图形
- hdu 5142 NPY and FFT(二进制处理)
- ZooKeeper基本原理
- 欢迎使用CSDN-markdown编辑器
- 严蔚敏数据结构:链表实现一元多项式相加
- HDU 1242 Rescue (第一道优先队列+BFS)
- HTML颜色
- 第一个工程3-代码解释一
- 数据源
- XML之------dom4j对XML文档增删改查