A8170 | Very Interesting Game
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
In a very ancient country the following game was popular. Two people play the game. Initially first player writes a string $s_{1}$ , consisting of exactly nine digits and representing a number that does not exceed $a$ . After that second player looks at $s_{1}$ and writes a string $s_{2}$ , consisting of exactly nine digits and representing a number that does not exceed $b$ . Here $a$ and $b$ are some given constants, $s_{1}$ and $s_{2}$ are chosen by the players. The strings are allowed to contain leading zeroes.
If a number obtained by the concatenation (joining together) of strings $s_{1}$ and $s_{2}$ is divisible by $mod$ , then the second player wins. Otherwise the first player wins. You are given numbers $a$ , $b$ , $mod$ . Your task is to determine who wins if both players play in the optimal manner. If the first player wins, you are also required to find the lexicographically minimum winning move.
If a number obtained by the concatenation (joining together) of strings $s_{1}$ and $s_{2}$ is divisible by $mod$ , then the second player wins. Otherwise the first player wins. You are given numbers $a$ , $b$ , $mod$ . Your task is to determine who wins if both players play in the optimal manner. If the first player wins, you are also required to find the lexicographically minimum winning move.
输入格式
The first line contains three integers $a$ , $b$ , $mod$ ( $0<=a,b<=10^{9}$ , $1<=mod<=10^{7}$ ).
输出格式
If the first player wins, print "1" and the lexicographically minimum string $s_{1}$ he has to write to win. If the second player wins, print the single number "2".
输入输出样例
输入 #1
1 10 7
输出 #1
2
输入 #2
4 0 9
输出 #2
1 000000001
The lexical comparison of strings is performed by the < operator in modern programming languages. String $x$ is lexicographically less than string $y$ if exists such $i$ ( $1<=i<=9$ ), that $x_{i}<y_{i}$ , and for any $j$ ( $1<=j<i$ ) $x_{j}=y_{j}$ . These strings always have length 9.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted