P26328 [AtCoder] Theme Color
普及+
题目描述

Problem Description

There is a class of $ N $ people, and they are to decide on a theme color by choosing one color from $ 1, 2, ..., M $.

When each person votes for one of the colors with equal probability, the probability that color $i (1 \leq i \leq M)$ receives $ r_i $ votes is denoted as $ p $.

Find the smallest integer $ x $ such that $p \geq 10^{-x}$.

It is guaranteed that the value of $ x $ remains unchanged even if $ p $ has a relative error of $ 10^{-6} $ or less.

Input Format

The input is given from the standard input in the following format:

$ N $ $ M $ $ r_1 $ $ r_2 $ $ ... $ $ r_M $

Output Format

Output the smallest integer $ x $ that satisfies $p \geq 10^{-x}$.

Sample Input and Output

Sample Input #1

3 2
1 2

Sample Output #1

1

Sample Input #2

120 5
18 36 31 12 23

Sample Output #2

8

Notes/Hints

Constraints

  • $1 \leq N \leq 10^5$
  • $1 \leq M \leq 10^5$
  • $0 \leq r_i \leq N$
  • $ r_1 + r_2 + ... + r_M = N $
  • All inputs are integers
  • The solution remains unchanged even if $ p $ has a relative error of $ 10^{-6} $ or less

Sample Explanation 1

Since $ p = 0.375 $, the smallest integer satisfying $p \geq 10^{-x}$ is $ 1 $.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
3 2 1 2
样例输出
1