HDU 5142 NPY and FFT 数的二进制倒转

NPY and FFT

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 187    Accepted Submission(s): 119

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?
Input
The first line contains a integer T — the number of queries ( 1T100 ).
The next T lines,each contains a integer X(0X2311 ),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
/*
HDU 5142 数的二进制倒转 
*/
#include<iostream>
#include<stdio.h>
using  namespace std;
int main()
{
	int t,i,j,num,k,ans,b,a[40];
	scanf("%d",&t);
	while(t--)
	{
		scanf("%d",&num);
		k=0;
		while(num)
		{
			if(num%2==1)
				a[k++]=1;
			else
				a[k++]=0;
			num/=2;
		}
		i=0;
		while(i<k)
		{
			if(a[i]==0)
				i++;
			else
				break;
		}
		b=1;
		ans=0;
		for(j=k-1;j>=i;j--)
		{
			if(a[j]==1)
				ans+=b;
			b*=2;	
		}
		printf("%d\n",ans);
	}
	
	
	
	
	return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Eclipse二进制文件是指由Eclipse集成开发环境生成的可执行文件。在Linux下,Eclipse生成的二进制文件通常是没有扩展名的,如上述引用所示。在使用Eclipse编译和运行项目时,如果项目名包含扩展名(例如.hdu.c),则Eclipse可能无法正确识别该文件为二进制可执行文件。 这可能导致在运行时出现找不到二进制文件的错误。解决办法有两种:一是避免使用带有扩展名的项目名,另一种是手动创建一个运行配置,将命令写死以确保正确识别为二进制文件。 需要注意的是,上述讨论中的EclipseParser库是一个用于验证和读取Eclipse二进制文件内容的DLL库,它是通过按照二进制格式编写的。这个库可以验证和读取Eclipse二进制文件中的EGRID、INIT、UNRST等内容。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [linux下eclipse c++运行不了提示找不到二进制文件的解决方法](https://blog.csdn.net/bjrxyz/article/details/8974483)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *2* *3* [Eclipse油藏值模拟软件的二进制文件格式解析](https://blog.csdn.net/slofslb/article/details/119176891)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值