A13593 | Captain Flint and Crew Recruitment
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Despite his bad reputation, Captain Flint is a friendly person (at least, friendly to animals). Now Captain Flint is searching worthy sailors to join his new crew (solely for peaceful purposes). A sailor is considered as worthy if he can solve Flint's task.
Recently, out of blue Captain Flint has been interested in math and even defined a new class of integers. Let's define a positive integer $x$ as nearly prime if it can be represented as $p \cdot q$ , where $1 < p < q$ and $p$ and $q$ are prime numbers. For example, integers $6$ and $10$ are nearly primes (since $2 \cdot 3 = 6$ and $2 \cdot 5 = 10$ ), but integers $1$ , $3$ , $4$ , $16$ , $17$ or $44$ are not.
Captain Flint guessed an integer $n$ and asked you: can you represent it as the sum of $4$ different positive integers where at least $3$ of them should be nearly prime.
Uncle Bogdan easily solved the task and joined the crew. Can you do the same?
Recently, out of blue Captain Flint has been interested in math and even defined a new class of integers. Let's define a positive integer $x$ as nearly prime if it can be represented as $p \cdot q$ , where $1 < p < q$ and $p$ and $q$ are prime numbers. For example, integers $6$ and $10$ are nearly primes (since $2 \cdot 3 = 6$ and $2 \cdot 5 = 10$ ), but integers $1$ , $3$ , $4$ , $16$ , $17$ or $44$ are not.
Captain Flint guessed an integer $n$ and asked you: can you represent it as the sum of $4$ different positive integers where at least $3$ of them should be nearly prime.
Uncle Bogdan easily solved the task and joined the crew. Can you do the same?
输入格式
The first line contains a single integer $t$ ( $1 \le t \le 1000$ ) — the number of test cases.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains the single integer $n$ $(1 \le n \le 2 \cdot 10^5)$ — the number Flint guessed.
Next $t$ lines contain test cases — one per line. The first and only line of each test case contains the single integer $n$ $(1 \le n \le 2 \cdot 10^5)$ — the number Flint guessed.
输出格式
For each test case print:
- YES and $4$ different positive integers such that at least $3$ of them are nearly prime and their sum is equal to $n$ (if there are multiple answers print any of them);
- NO if there is no way to represent $n$ as the sum of $4$ different positive integers where at least $3$ of them are nearly prime.
You can print each character of YES or NO in any case.
- YES and $4$ different positive integers such that at least $3$ of them are nearly prime and their sum is equal to $n$ (if there are multiple answers print any of them);
- NO if there is no way to represent $n$ as the sum of $4$ different positive integers where at least $3$ of them are nearly prime.
You can print each character of YES or NO in any case.
输入输出样例
输入 #1
7 7 23 31 36 44 100 258
输出 #1
NO NO YES 14 10 6 1 YES 5 6 10 15 YES 6 7 10 21 YES 2 10 33 55 YES 10 21 221 6
In the first and second test cases, it can be proven that there are no four different positive integers such that at least three of them are nearly prime.
In the third test case, $n=31=2 \cdot 7 + 2 \cdot 5 + 2 \cdot 3 + 1$ : integers $14$ , $10$ , $6$ are nearly prime.
In the fourth test case, $n=36=5 + 2 \cdot 3 + 2 \cdot 5 + 3 \cdot 5$ : integers $6$ , $10$ , $15$ are nearly prime.
In the fifth test case, $n=44=2 \cdot 3 + 7 + 2 \cdot 5 + 3 \cdot 7$ : integers $6$ , $10$ , $21$ are nearly prime.
In the sixth test case, $n=100=2 + 2 \cdot 5 + 3 \cdot 11 + 5 \cdot 11$ : integers $10$ , $33$ , $55$ are nearly prime.
In the seventh test case, $n=258=2 \cdot 5 + 3 \cdot 7 + 13 \cdot 17 + 2 \cdot 3$ : integers $10$ , $21$ , $221$ , $6$ are nearly prime.
In the third test case, $n=31=2 \cdot 7 + 2 \cdot 5 + 2 \cdot 3 + 1$ : integers $14$ , $10$ , $6$ are nearly prime.
In the fourth test case, $n=36=5 + 2 \cdot 3 + 2 \cdot 5 + 3 \cdot 5$ : integers $6$ , $10$ , $15$ are nearly prime.
In the fifth test case, $n=44=2 \cdot 3 + 7 + 2 \cdot 5 + 3 \cdot 7$ : integers $6$ , $10$ , $21$ are nearly prime.
In the sixth test case, $n=100=2 + 2 \cdot 5 + 3 \cdot 11 + 5 \cdot 11$ : integers $10$ , $33$ , $55$ are nearly prime.
In the seventh test case, $n=258=2 \cdot 5 + 3 \cdot 7 + 13 \cdot 17 + 2 \cdot 3$ : integers $10$ , $21$ , $221$ , $6$ are nearly prime.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted