제출 #290506

#제출 시각아이디문제언어결과실행 시간메모리
290506luciocfNice sequence (IZhO18_sequence)C++14
6 / 100
1 ms384 KiB
#include <bits/stdc++.h>

using namespace std;

const int maxn = 2e5+10;

int a[maxn];

int main(void)
{
	int tc;
	cin >> tc;

	while (tc--)
	{
		int n, m;
		cin >> n >> m;

		if (max(n, m)%min(n, m) == 0)
		{
			if (n > m)
			{
				cout << n-1 << "\n";
				for (int i = 1; i < n; i++)
					cout << "1 ";
				cout << "\n";
			}
			else
			{
				cout << m-1 << "\n";
				for (int i = 1; i < m; i++)
					cout << "-1 ";
				cout << "\n";
			}
		}
		else
		{
			if (m == 2)
			{
				if (n == 3)
				{
					cout << "3\n-3 4 -3\n";
				}
				else
				{
					cout << n-1 << "\n";
					for (int i = 1; i < n; i++)
						cout << "1 ";
					cout << "\n";
				}
			}
			else
			{
				if (m == 3)
				{
					cout << "3\n3 -4 2\n";
				}
				else
				{
					cout << m-1 << "\n";
					for (int i = 1; i < m; i++)
						cout << "-1 ";
					cout << "\n";
				}
			}
		}
	}
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...