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

23907번 - Perfect Subarray 서브태스크다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
서브태스크 참고 (추가 시간 없음) 1024 MB112342233.846%

문제

Cristobal has an array of N (possibly negative) integers. The i-th integer in his array is Ai. A contiguous non-empty subarray of Cristobal's array is perfect if its total sum is a perfect square. A perfect square is a number that is the product of a non-negative integer with itself. For example, the first five perfect squares are 0, 1, 4, 9 and 16.

How many subarrays are perfect? Two subarrays are different if they start or end at different indices in the array, even if the subarrays contain the same values in the same order.

입력

The first line of the input gives the number of test cases, T. T test cases follow. The first line of each test case contains the integer N. The second line contains N integers describing Cristobal's array. The i-th integer is Ai.

출력

For each test case, output one line containing Case #x: y, where x is the test case number (starting from 1) and y is the number of perfect subarrays.

제한

  • 1 ≤ T ≤ 100.
  • -100 ≤ Ai ≤ 100, for all i.

Test Set 1 (10점)

시간 제한: 20 초

  • 1 ≤ N ≤ 1000.

Test Set 2 (19점)

시간 제한: 30 초

  • For up to 5 cases, 1 ≤ N ≤ 105.
  • For the remaining cases, 1 ≤ N ≤ 1000.

예제 입력 1

3
3
2 2 6
5
30 30 9 1 30
4
4 0 0 16

예제 출력 1

Case #1: 1
Case #2: 3
Case #3: 9

힌트

In sample case #1, there is one perfect subarray: [2 2] whose sum is 22.

In sample case #2, there are three perfect subarrays:

  • [9], whose total sum is 32.
  • [1], whose total sum is 12.
  • [30 30 9 1 30], whose total sum is 102.

In sample case #3, there are nine perfect subarrays:

  • [4], whose total sum is 22.
  • [4 0], whose total sum is 22.
  • [4 0 0], whose total sum is 22.
  • [0], whose total sum is 02.
  • [0 0], whose total sum is 02.
  • [0 0 16], whose total sum is 42.
  • [0], whose total sum is 02.
  • [0 16], whose total sum is 42.
  • [16], whose total sum is 42.

Note: We do not recommend using interpreted/slower languages for the test set 2 of this problem.

출처

Contest > Google > Kick Start > Google Kick Start 2020 > Round C C번

채점 및 기타 정보

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

출처

대학교 대회

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

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