本文章由 WyOJ Shojo 从洛谷专栏拉取,原发布时间为 2022-04-11 18:48:55
题意:
给你 $t$ 个整数,让我们求四个数 $a,b,c,d$,并且 $a + b + c + d = n$ 并且 $\gcd(a , b)$ $= \operatorname{lcm(c , d)}$。
题解思路:
我们先输出一个 $n - 3$,然后再输 $3$ 个 $1$,即可,因为 $n - 3 + 1 + 1 + 1 = n - 3 + 3 = n$。
在来看后面的满足,后面要求 $\gcd (a , b) = \lcm (c , d)$,那么由于任何一个数都是 $1$ 的倍数,所以 $\gcd(a , b)$ 一定等于 $1$。
而两个 $1$ 的最小公倍数就是 $1$,$1 = 1$ 所以这种方法可行。
AC Code:
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
int T;
int main() {
cin >> T;
while (T --) {
int n;
cin >> n;
cout << n - 3 << ' ';\/\/先输出一个n-1
for (int i = 1; i <= 3; ++ i)
cout << 1 << ' ';\/\/再输出3个1
cout << endl;
}
return 0;
}

鲁ICP备2025150228号