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

23989번 - Square Counting 서브태스크다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
20 초 (추가 시간 없음) 1024 MB55372670.270%

문제

Mr. Panda has recently fallen in love with a new game called Square Off, in which players compete to find as many different squares as possible on an evenly spaced rectangular grid of dots. To find a square, a player must identify four dots that form the vertices of a square. Each side of the square must have the same length, of course, but it does not matter what that length is, and the square does not necessarily need to be aligned with the axes of the grid. The player earns one point for every different square found in this way. Two squares are different if and only if their sets of four dots are different.

Mr. Panda has just been given a grid with R rows and C columns of dots. How many different squares can he find in this grid? Since the number might be very large, please output the answer modulo 109 + 7 (1000000007).

입력

The first line of the input gives the number of test cases, T. T lines follow. Each line has two integers R and C: the number of dots in each row and column of the grid, respectively.

출력

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 different squares can be found in the grid.

제한

  • 1 ≤ T ≤ 100.

Test Set 1 (8점)

  • 2 ≤ R ≤ 1000.
  • 2 ≤ C ≤ 1000.

Test Set 2 (17점)

  • 2 ≤ R ≤ 109.
  • 2 ≤ C ≤ 109.

예제 입력 1

4
2 4
3 4
4 4
1000 500

예제 출력 1

Case #1: 3
Case #2: 10
Case #3: 20
Case #4: 624937395

힌트

The pictures below illustrate the grids from the three sample cases and a valid square in the third sample case.

출처

Contest > Google > Kick Start > Google Kick Start 2017 > Round A A번

채점 및 기타 정보

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

출처

대학교 대회

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

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