Logo
(追記) (追記ここまで)

27910번 - Logaritam 서브태스크다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 1024 MB30201768.000%

문제

Hrvoje has recently learned about the logarithm function. He really likes the property $\log(xy) = \log(x) + \log(y),ドル for each pair of positive real numbers $x$ and $y$.

He is actually not interested in the function itself, but in logarithmic sequences. A logarithmic sequence of length $n$ is a sequence of real numbers $(a_1, a_2, \dots , a_n)$ for which $a_{xy} = a_x + a_y$ holds for every pair of positive integers $x$ and $y$ such that $xy ≤ n$. An example of a logarithmic sequence of length 6ドル$ is 0,ドル 1, π, 2, 0.7, 1 + π$.

For his homework, Hrvoje needed to write $q$ logarithmic sequences of length $n,ドル however, after a long night of effort he woke up just to find out that Matej had changed exactly one element of each sequence. Hrvoje doesn’t have a lot of time to correct his homework, so he is interested in the least number of elements of each sequence he needs to change so the sequence becomes logarithmic again. Unfortunately, Matej had written his element with a pen, so Hrvoje cannot change that element of the sequence.

Hrvoje has forgotten which sequences he wrote for his homework so the only thing he knows is the number of sequences $q,ドル the length of each sequence $n$ and the position $x_i$ of the element Matej had changed in the i-th sequence.

Note: It can be proven that for any starting logarithmic sequence the minimal number of changes is the same.

입력

In the first line there are two positive integers $n$ and $q$ (1ドル ≤ n ≤ 10^8,ドル 1ドル ≤ q ≤ 10^4$), the length of each sequence and the number of sequences.

In the $i$-th of the next $q$ lines there is a positive integer $x_i$ (1ドル ≤ x_i ≤ n$), the index of the element Matej had changed in the $i$-th sequence.

출력

In the $i$-th line output -1 if Hrvoje cannot change the other elements of the $i$-th sequence such that the sequence becomes logarithmic again, otherwise output the minimal number of changes needed to make the sequence logarithmic again.

제한

서브태스크

번호배점제한
119

$n ≤ 20,ドル $q ≤ 20$

226

$q ≤ 8$

329

$n ≤ 10^4$

436

No additional constraints.

예제 입력 1

6 6
1
2
3
4
5
6

예제 출력 1

-1
2
1
2
0
1

예제 입력 2

20 5
7
8
2
19
12

예제 출력 2

1
9
9
0
5

예제 입력 3

10000 4
1234
2345
3456
7890

예제 출력 3

15
148
3332
37

힌트

Clarification of the first example: If the starting sequence was 0,ドル 1, π, 2, 0.7, 1 + π$ and Matej changes the fourth element to 8ドル,ドル Hrvoje can change the second element to 4ドル$ and the sixth to 4ドル + π,ドル after which the sequence 0,ドル 4, π, 8, 0.7, 4 + π$ will be logarithmic again.

출처

Contest > Croatian Open Competition in Informatics > COCI 2022/2023 > Contest #5 3번

채점 및 기타 정보

  • 예제는 채점하지 않는다.
(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /