devC++输入输出结果和平台不同
查看原帖
devC++输入输出结果和平台不同
742226
chen3416707964楼主2023/10/6 13:34
#include<bits/stdc++.h>
using namespace std;
int n, x=30, t[31], cnt=0; 
int main(){
	cin>>n;
	if(n%2){
		cout<<-1;
		return 0;
	}
	while(n){
		int temp = 1<<x;
		if(n>=temp){
			n-=temp; t[x]++; cnt++;
		}
		x--;
	}
	if(cnt<=1){
		cout<<-1;
		return 0;
	}
	for(int i=30; i>0; i--){
		if(t[i]) cout<<int(pow(2, i))<<" ";
	}
	return 0;
}

在dev中运行输入8,得到结果为-1,下载错误的测试点中.in(输入文件)文件内容8,.out(输出文件)文件中内容也为8,什么原因导致的

2023/10/6 13:34
加载中...