60求大神
查看原帖
60求大神
940105
hp1596321楼主2023/3/27 16:52
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>





int main()
{
	int n = 0;
	scanf("%d", &n);
	
	
	
	int i = 0;
	if (n % 2 != 0)
	{
		printf("-1");
		return 0;
	}
	long long x = 1;
	int j = 0;
	while (x < n)
	{
		x = x * 2;
		j++;
	}//最大的j
	if (x>n)
		j = j - 1;

	while (n)
	{
		printf("%d ", (int)pow(2, j));
			n = n - pow(2, j);
	    
			 if (n < 0)
				n = n + pow(2, j);
			
			j--;
	}
	
		

	return 0;
	


	

}
2023/3/27 16:52
加载中...