求助,着急。谢谢。PJT1。
  • 板块学术版
  • 楼主lmrttx
  • 当前回复20
  • 已保存回复20
  • 发布时间2020/11/8 11:47
  • 上次更新2023/11/5 08:29:53
查看原帖
求助,着急。谢谢。PJT1。
344382
lmrttx楼主2020/11/8 11:47

样例都过,手造数据也过,感觉代码也没问题,为什么洛谷民间数据才20分!!!

好着急啊,今年绝对不能砸啊,不然准备退役了......

#include<iostream>
#include<cstdio>
#include<cstring>
#define ll long long
using namespace std;

inline ll read(){
	ll s=0,w=1;char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-')w=-1;ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		s=(s<<3)+(s<<1)+(ch^48);
		ch=getchar();
	}
	return s*w;
}

inline ll qpow(ll a,ll b){
	ll res=1;
	while(b){
		if(b&1)res=res*a;
		a=a*a;b>>=1;
	}
	return res;
}

void end(){
	puts("-1");
}

ll n,last=23,b[24];

void print(){
	for(ll i=last+1;i<=23;i++)
	printf("%lld ",b[i]);
}

int main(){
	n=read();
	if(n==1||n==0){
		end();return 0;
	}
	if(n&1){
		end();return 0;
	}
	for(ll i=1;i<=23;i++){
		ll hh=qpow(2,i);
		n-=hh;
		b[last--]=hh;
		if(n==1){
			end();return 0;
		}
		if(n==0){
			print();return 0;
		}
	}
	if(n<0){
		end();return 0;
	}
	return 0;
}
2020/11/8 11:47
加载中...