A10392 | Robbers' watch
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Robbers, who attacked the Gerda's cab, are very successful in covering from the kingdom police. To make the goal of catching them even harder, they use their own watches.
First, as they know that kingdom police is bad at math, robbers use the positional numeral system with base $7$ . Second, they divide one day in $n$ hours, and each hour in $m$ minutes. Personal watches of each robber are divided in two parts: first of them has the smallest possible number of places that is necessary to display any integer from $0$ to $n-1$ , while the second has the smallest possible number of places that is necessary to display any integer from $0$ to $m-1$ . Finally, if some value of hours or minutes can be displayed using less number of places in base $7$ than this watches have, the required number of zeroes is added at the beginning of notation.
Note that to display number $0$ section of the watches is required to have at least one place.
Little robber wants to know the number of moments of time (particular values of hours and minutes), such that all digits displayed on the watches are distinct. Help her calculate this number.
First, as they know that kingdom police is bad at math, robbers use the positional numeral system with base $7$ . Second, they divide one day in $n$ hours, and each hour in $m$ minutes. Personal watches of each robber are divided in two parts: first of them has the smallest possible number of places that is necessary to display any integer from $0$ to $n-1$ , while the second has the smallest possible number of places that is necessary to display any integer from $0$ to $m-1$ . Finally, if some value of hours or minutes can be displayed using less number of places in base $7$ than this watches have, the required number of zeroes is added at the beginning of notation.
Note that to display number $0$ section of the watches is required to have at least one place.
Little robber wants to know the number of moments of time (particular values of hours and minutes), such that all digits displayed on the watches are distinct. Help her calculate this number.
输入格式
The first line of the input contains two integers, given in the decimal notation, $n$ and $m$ ( $1<=n,m<=10^{9}$ ) — the number of hours in one day and the number of minutes in one hour, respectively.
输出格式
Print one integer in decimal notation — the number of different pairs of hour and minute, such that all digits displayed on the watches are distinct.
输入输出样例
输入 #1
2 3
输出 #1
4
输入 #2
8 2
输出 #2
5
In the first sample, possible pairs are: $(0:1)$ , $(0:2)$ , $(1:0)$ , $(1:2)$ .
In the second sample, possible pairs are: $(02:1)$ , $(03:1)$ , $(04:1)$ , $(05:1)$ , $(06:1)$ .
In the second sample, possible pairs are: $(02:1)$ , $(03:1)$ , $(04:1)$ , $(05:1)$ , $(06:1)$ .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted