305215: CF991E. Bus Number

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Bus Number

题意翻译

给你一个数字序列A(长度不超过18位),问有多少个序列B满足①A中所有数字都一定要在B中出现过;②B中所有数字也一定要在A中出现过;③序列B不能以0开头

题目描述

This night wasn't easy on Vasya. His favorite team lost, and he didn't find himself victorious either — although he played perfectly, his teammates let him down every time. He had to win at least one more time, but the losestreak only grew longer and longer... It's no wonder he didn't get any sleep this night at all. In the morning, Vasya was waiting the bus to the university on the bus stop. Vasya's thoughts were hazy and so he couldn't remember the right bus' number quite right and got onto the bus with the number $ n $ . In the bus, Vasya thought that he could get the order of the digits in the number of the bus wrong. Futhermore, he could "see" some digits several times, but the digits he saw were definitely in the real number of the bus. For example, if Vasya saw the number 2028, it could mean that the real bus number could be 2028, 8022, 2820 or just 820. However, numbers 80, 22208, 52 definitely couldn't be the number of the bus. Also, real bus number couldn't start with the digit 0, this meaning that, for example, number 082 couldn't be the real bus number too. Given $ n $ , determine the total number of possible bus number variants.

输入输出格式

输入格式


The first line contains one integer $ n $ ( $ 1 \leq n \leq 10^{18} $ ) — the number of the bus that was seen by Vasya. It is guaranteed that this number does not start with $ 0 $ .

输出格式


Output a single integer — the amount of possible variants of the real bus number.

输入输出样例

输入样例 #1

97

输出样例 #1

2

输入样例 #2

2028

输出样例 #2

13

说明

In the first sample, only variants $ 97 $ and $ 79 $ are possible. In the second sample, the variants (in the increasing order) are the following: $ 208 $ , $ 280 $ , $ 802 $ , $ 820 $ , $ 2028 $ , $ 2082 $ , $ 2208 $ , $ 2280 $ , $ 2802 $ , $ 2820 $ , $ 8022 $ , $ 8202 $ , $ 8220 $ .

Input

题意翻译

给你一个数字序列A(长度不超过18位),问有多少个序列B满足①A中所有数字都一定要在B中出现过;②B中所有数字也一定要在A中出现过;③序列B不能以0开头

加入题单

上一题 下一题 算法标签: