A16363 | Sum of Three
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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.
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.
输入格式
The first line contains a single integer $t$ ( $1 \le t \le 10^4$ ) — the number of testcases.
The only line of each testcase contains a single integer $n$ ( $1 \le n \le 10^{9}$ ).
The only line of each testcase contains a single integer $n$ ( $1 \le n \le 10^{9}$ ).
输出格式
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.
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.
输入输出样例
输入 #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.
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.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted