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

9728번 - Pair Sum 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 128 MB37426421270.903%

문제

You are given an integer array of size N and an integer M. This array has (N*(N-1))/2 different pairs. You need to calculate how many of those pairs have the sum equal to M. For example, if the array is {1,2,3,4} and M is 5, then there are exactly 2 pairs {1,4} and {2,3} whose sum is equal to M.

입력

The first line has a positive integer T, T <= 100,000, denoting the number of test cases. This is followed by each test case per line.

Each test case consists of two lines. The first line contains 2 integers N and M separated by a single space. N is between 2 and 20,000 inclusive. The second line consists of the N integers separated by a single space, denoting the values of the given array. All the numbers in the array are between 1 and 1,000,000,000 inclusive. They are distinct and sorted in increasing order.

출력

For each test case, the output contains a line in the format Case #x: R, where x is the case number (starting from 1) and R is the number of pairs whose sum is exactly the given M.

제한

예제 입력 1

5
8 100
19 25 32 48 52 68 75 81
8 100
19 28 31 49 51 61 72 81
8 100
16 22 38 46 58 62 73 81
8 100
13 21 32 48 52 67 78 87
8 100
13 24 34 43 57 61 76 81

예제 출력 1

Case #1: 4
Case #2: 3
Case #3: 1
Case #4: 2
Case #5: 2

힌트

출처

ICPC > Regionals > Asia Pacific > Malaysia > Malaysia National Programming Contest > Al-Khawarizmi National Programming Contest 2010 F번

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

출처

대학교 대회

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

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