CF1886A.Sum of Three
入门
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Monocarp has an integer n.
He wants to represent his number as a sum of three distinct positive integers x, y, and z. Additionally, Monocarp wants none of the numbers x, y, and z to be divisible by 3.
Your task is to help Monocarp to find any valid triplet of distinct positive integers x, y, and z, or report that such a triplet does not exist.
Monocarp 有一个整数 n。
他希望将该数表示为三个互不相同的正整数 x、y 和 z 的和。此外,Monocarp 要求 x、y、z 中任意一个都不能被 3 整除。
你的任务是帮助 Monocarp 找出任意一组满足条件的互不相同的正整数三元组 (x,y,z);若不存在这样的三元组,则报告其不存在。
输入格式
The first line contains a single integer t (1≤t≤104) — the number of testcases.
The only line of each testcase contains a single integer n (1≤n≤109).
第一行包含一个整数 t(1≤t≤104)—— 表示测试用例的数量。
每个测试用例仅有一行,包含一个整数 n(1≤n≤109)。
输出格式
For each testcase, if there is no valid triplet x, y, and z, print NO on the first line.
Otherwise, print YES on the first line. On the second line, print any valid triplet of distinct positive integers x, y, and z such that x+y+z=n, and none of the printed numbers are divisible by 3. If there are multiple valid triplets, you can print any of them.
对于每个测试用例,若不存在满足条件的三元组 x、y 和 z,则在第一行输出 NO。
否则,在第一行输出 YES;在第二行输出任意一组满足条件的互不相同的正整数三元组 x、y、z,使得 x+y+z=n,且输出的三个数均不能被 3 整除。若存在多组满足条件的三元组,输出任意一组即可。
输入输出样例
输入#1
4 10 4 15 9
输出#1
YES 4 5 1 NO YES 2 8 5 NO
说明/提示
In the first testcase, one of the valid triplets is x=4, y=5, z=1. None of these numbers are divisible by three, and 4+5+1=10.
In the second testcase, there is no valid triplet.
In the third testcase, one of the valid triplets is x=2, y=8, z=5. None of these numbers are divisible by three, and 2+8+5=15.
In the fourth testcase, there is no valid triplet.
在第一个测试用例中,一个合法的三元组是 x=4、y=5、z=1。这三个数均不能被 3 整除,且 4+5+1=10。
在第二个测试用例中,不存在合法的三元组。
在第三个测试用例中,一个合法的三元组是 x=2、y=8、z=5。这三个数均不能被 3 整除,且 2+8+5=15。
在第四个测试用例中,不存在合法的三元组。
输入解题思路,AI测评打分。不知道怎么写?