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

34610번 - Squares on Grid Lines 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
4 초 2048 MB74457.143%

문제

You have a square of side length $n$ on a 2D plane, partitioned into a grid of 1ドル \times 1$ square cells, totaling $n^2$ cells.

Your task is to answer $q$ queries, numbered from 1ドル$ to $q,ドル described below. In query $i,ドル you are given a real number $s_i,ドル and you must count the number of ways to place four points on the plane such that

  • each point lies on the boundary of a cell (not necessarily the same), and
  • the four points form the vertices of a square with area $s_i$.

Here, the edges of the square formed by these points do not need to be parallel to the edges of the cells. If there are infinitely many valid placements, you must report that as your answer.

Two placements are considered different if there exists a point that appears in one placement but not in the other.

입력

The first line of input contains two integers $n$ and $q$ (1ドル ≤ n ≤ 2000,ドル 1ドル ≤ q ≤ 100,円 000$). The $i$-th of the next $q$ lines contains a real number $s_i$ (0ドル.01 ≤ s_i ≤ n^2$), given with exactly two digits after the decimal point.

출력

Output $q$ lines. The $i$-th line should contain the number of valid placements for query $i$. If infinitely many exist, output -1 instead.

제한

예제 입력 1

3 4
6.90
0.26
2.65
1.00

예제 출력 1

2
4
10
-1

For queries 1ドル$ and 2ドル,ドル the valid placements are illustrated in Figure I.1. The top two placements correspond to query 1ドル,ドル and the bottom four correspond to query 2ドル$. In each placement, the shaded region represents a square formed by the points.

Figure I.1: Illustrations of Sample Input #1.

예제 입력 2

1 5
0.49
0.50
0.51
0.99
1.00

예제 출력 2

0
1
2
2
1

노트

출처

ICPC > Regionals > Asia Pacific > Asia Pacific Championship > The 2025 ICPC Asia Pacific Championship I번

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

출처

대학교 대회

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

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