포럼
문제 COCI00466

Sazetak

설명

An unknown array \(x\) consists of N integers. The K-summary of that array is obtained by
dividing the array into segments of length K and summing up the elements in each segment.
If N is not divisible by K, the last segment of the division will have less than K elements.
In other words, the K-summary is an array where the elements are, respectively: (\(x\)[1] + ... +
\(x\)[K]), (\(x\)[\(K+1\)] + ... + \(x\)[2K]), and so on, where the last sum that contains \(x\)[N] can have less
than K summands. For example, the 5-summary of an array of 13 elements has three
elements (sum of elements 1.-5., sum of elements 6.-10., sum of elements 11.-13.).
It is clear that we cannot reconstruct the elements of the original array from the K-summary,
but that might be possible if we knew several K-summaries for different Ks. Write a program
that will, given length N and set K_{1}, K_{2}, ..., K_{M}, predict how many elements of the original
array we would be able to uniquely determine if we knew all the \(K_{i}-su\)mmaries of the array.
(It is not difficult to show that the number of reconstructed elements is independent of the
content of the summaries.)

제약

In test cases worth 40% of total points, it will hold N <= 5 000 000.

입력 형식

The first line contains the integers \(N\) and \(M\) (3 <= N <= \(10^{9}\), 1 <= M <= 10), the array length
and the number of K-summaries.
The second line contains distinct integers K_{1}, K_{2}, ..., K_{M} (2 <= \(K_{i} < N\)) from the task.

출력 형식

You must output the required number of reconstructed elements.

예제 1
입력
3 1
2
출력
1
예제 2
입력
6 2
2 3
출력
2
예제 3
입력
123456789 3
5 6 9
출력
10973937
문제 정보

생성자가 기록되지 않았습니다.

출처 COCI 2017/2018 Contest 3

평가 및 의견

Sazetak

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 1 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

Sazetak

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8