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

15837번 - Sum of Subrectangle Areas 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB2311087343.713%

문제

The following code snippet calculates the sum of the areas of all the sub rectangular grid in a rectangular grid from (0,0) to (N,N). Find an efficient way to compute that.

sum = 0
for r1 = 0 to N-1
 for c1 = 0 to N-1
 for r2 = r1+1 to N
 for c2 = r2+1 to N
 sum = sum + (r2-r1)*(c2-c1)
print(sum)

입력

Input starts with T the number of test cases. Each test case consists of a single integer N.

출력

For each test output the sum (as computed above). Please note that even though N will fit into 64 bit integer, the sum may not be.

제한

예제 입력 1

5
1
2
3
4
1000

예제 출력 1

1
16
100
400
27944805889000000

힌트

출처

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

  • 문제의 오타를 찾은 사람: jh05013
(追記) (追記ここまで)

출처

대학교 대회

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

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