跳到正文

题解

题解:P11007 『STA - R7』Odtlcsu

csh7306jjj约 1 分钟
原文
文章信息与版本

文章信息

发布
2024年8月26日
收录
2026年11月26日
更新
2026年11月26日
篇幅
约 1 分钟
题目
P11007

版本

  1. v1当前

这道题其实很简单,因为 11 的平方和 −1-1 的平方都是 11,所以只需要使 11 的个数比 −1-1 的个数多 xx,并且 11 和 −1-1 的个数之和为 yy,即可做出

C++
#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;
}
原文