시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 14432 4955 4002 36.422%

문제

양의 정수 n개가 주어졌을 때, 가능한 모든 쌍의 GCD의 합을 구하는 프로그램을 작성하시오.

입력

첫째 줄에 테스트 케이스의 개수 t (1 ≤ t ≤ 100)이 주어진다. 각 테스트 케이스는 한 줄로 이루어져 있다. 각 테스트 케이스는 수의 개수 n (1 < n ≤ 100)가 주어지고, 다음에는 n개의 수가 주어진다. 입력으로 주어지는 수는 1,000,000을 넘지 않는다.

출력

각 테스트 케이스마다 가능한 모든 쌍의 GCD의 합을 출력한다.

예제 입력 1

3
4 10 20 30 40
3 7 5 12
3 125 15 25

예제 출력 1

70
3
35
W3sicHJvYmxlbV9pZCI6Ijk2MTMiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJHQ0QgXHVkNTY5IiwiZGVzY3JpcHRpb24iOiI8cD5cdWM1OTFcdWM3NTggXHVjODE1XHVjMjE4IG5cdWFjMWNcdWFjMDAgXHVjOGZjXHVjNWI0XHVjODRjXHVjNzQ0IFx1YjU0YywgXHVhYzAwXHViMmE1XHVkNTVjIFx1YmFhOFx1YjRlMCBcdWMzMGRcdWM3NTggR0NEXHVjNzU4IFx1ZDU2OVx1Yzc0NCBcdWFkNmNcdWQ1NThcdWIyOTQgXHVkNTA0XHViODVjXHVhZGY4XHViN2E4XHVjNzQ0IFx1Yzc5MVx1YzEzMVx1ZDU1OFx1YzJkY1x1YzYyNC48XC9wPlxyXG4iLCJpbnB1dCI6IjxwPlx1Y2NhYlx1YzlmOCBcdWM5MDRcdWM1ZDAgXHVkMTRjXHVjMmE0XHVkMmI4IFx1Y2YwMFx1Yzc3NFx1YzJhNFx1Yzc1OCBcdWFjMWNcdWMyMTggdCAoMSAmbGU7IHQgJmxlOyAxMDApXHVjNzc0IFx1YzhmY1x1YzViNFx1YzljNFx1YjJlNC4gXHVhYzAxIFx1ZDE0Y1x1YzJhNFx1ZDJiOCBcdWNmMDBcdWM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lvbiBvZiBHQ0QgKGdyZWF0ZXN0IGNvbW1vbiBkaXZpc29yKSBvZiBldmVyeSBwb3NzaWJsZSBwYWlyIG9mIHRoZXNlIGludGVnZXJzLiZuYnNwOzxcL3A+XHJcbiIsImlucHV0IjoiPHA+VGhlIGZpcnN0IGxpbmUgb2YgaW5wdXQgaXMgYW4gaW50ZWdlciBuICgxJmx0OyBuICZsdDsxMDApIHRoYXQgZGV0ZXJtaW5lcyB0aGUgbnVtYmVyIG9mIHRlc3QgY2FzZXMuIFRoZSBmb2xsb3dpbmcgbiBsaW5lcyBhcmUgdGhlIG4gdGVzdCBjYXNlcy4gRWFjaCB0ZXN0IGNhc2UgY29udGFpbnMgMiBwYXJ0czogZmlyc3QgcGFydCBpcyB0aGUgbnVtYmVyIG0gKDEmbHQ7IG0gJmx0OzEwMCkgaW5kaWNhdGluZyB0aGUgbnVtYmVyIG9mIGlucHV0IGludGVnZXJzLCBzZWNvbmQgcGFydCBpbmNsdWRlcyBtIHBvc2l0aXZlIGludGVnZXJzLiBUaGUgaW5wdXQgaW50ZWdlcnMgZG8gbm90IGV4Y2VlZCAxMDAwMDAwLiZuYnNwOzxcL3A+XHJcbiIsIm91dHB1dCI6IjxwPkZvciBlYWNoIHRlc3QgY2FzZSwgc2hvdyB0aGUgc3VtbWF0aW9uIG9mIEdDRHMgb2YgZXZlcnkgcG9zc2libGUgcGFpci4mbmJzcDs8XC9wPlxyXG4iLCJoaW50IjoiIiwib3JpZ2luYWwiOiIxIiwicHJvYmxlbV9sYW5nX2NvZGUiOiJcdWM2MDFcdWM1YjQifV0=

출처

ICPC > Regionals > Asia Pacific > Thailand > 2013 ACM-ICPC Asia Phuket Regional Programming Contest PE번

  • 어색한 표현을 찾은 사람: alkyne
  • 문제를 번역한 사람: baekjoon
  • 잘못된 데이터를 찾은 사람: tncks0121
  • 데이터를 추가한 사람: topology