A8438 | Win or Freeze
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
You can't possibly imagine how cold our friends are this winter in Nvodsk! Two of them play the following game to warm up: initially a piece of paper has an integer $q$ . During a move a player should write any integer number that is a non-trivial divisor of the last written number. Then he should run this number of circles around the hotel. Let us remind you that a number's divisor is called non-trivial if it is different from one and from the divided number itself.
The first person who can't make a move wins as he continues to lie in his warm bed under three blankets while the other one keeps running. Determine which player wins considering that both players play optimally. If the first player wins, print any winning first move.
The first person who can't make a move wins as he continues to lie in his warm bed under three blankets while the other one keeps running. Determine which player wins considering that both players play optimally. If the first player wins, print any winning first move.
输入格式
The first line contains the only integer $q$ ( $1<=q<=10^{13}$ ).
Please do not use the %lld specificator to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specificator.
Please do not use the %lld specificator to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specificator.
输出格式
In the first line print the number of the winning player ( $1$ or $2$ ). If the first player wins then the second line should contain another integer — his first move (if the first player can't even make the first move, print $0$ ). If there are multiple solutions, print any of them.
输入输出样例
输入 #1
6
输出 #1
2
输入 #2
30
输出 #2
1 6
输入 #3
1
输出 #3
1 0
Number $6$ has only two non-trivial divisors: $2$ and $3$ . It is impossible to make a move after the numbers $2$ and $3$ are written, so both of them are winning, thus, number $6$ is the losing number. A player can make a move and write number $6$ after number $30$ ; $6$ , as we know, is a losing number. Thus, this move will bring us the victory.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted