这道题其实很简单,因为 的平方和 的平方都是 ,所以只需要使 的个数比 的个数多 ,并且 和 的个数之和为 ,即可做出
#include<bits/stdc++.h>
#define int long long
using namespace std;
inline int R() {int x = 0;bool f = 1;char ch = getchar();while (!isdigit(ch)) f = ch == '-' ? 0 : 1, ch = getchar();while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();return f ? x : -x;}//快读
const int N=6e5+10,M=1e5;
int n,m,ans,t,tt,x[N];
signed main(){
cin>>n>>m;
t=(m+n)/2;//1的个数
tt=m-t;//-1的个数
cout<<m<<endl;
while(t--) cout<<1<<" ";
while(tt--) cout<<-1<<" ";
return 0;
}