시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 14 14 12 100.000%

문제

모든 자연수 N은 (2a)(3b)의 합으로 나타낼 수 있다. 이때, 서로 약수/배수 관계인 두 항이 있어서는 안 된다.

  • 1 = (20)(30)
  • 7 = (22)(30) + (20)(31)
  • 31 = (24)(30) + (20)(32) + (21)(31) = (22)(30) + (20)(33)

N이 주어졌을 때, 이를 (2a)(3b)의 합으로 나타내는 프로그램을 작성하시오.

입력

첫째 줄에 테스트 케이스의 개수 T(1<=T<=1,000)가 주어진다. 각 테스트 케이스는 한줄로 이루어져 있고, 정수 N이 주어진다. (1 <= N < 231)

출력

각 테스트 케이스에 대해 첫째 줄에는 항의 개수 M을 출력한다. 그다음 M개의 줄에 걸쳐 합을 구성하는 항을 출력한다. 어떤 항이 (2a)(3b)일때, a b를 공백으로 구분하여 출력하면 된다.

예제 입력 1

6
1
7
31
7776
531441
123456789

예제 출력 1

1
0 0
2
2 0
0 1
3
4 0
0 2
1 1
1
5 5
1
0 12
8
3 13
4 12
2 15
7 8
9 6
0 16
10 5
15 2
W3sicHJvYmxlbV9pZCI6IjI3MjciLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiIyLDMgXHVhYzcwXHViNGVkXHVjODFjXHVhY2YxXHVjNzU4IFx1ZDU2OSIsImRlc2NyaXB0aW9uIjoiPHA+XHViYWE4XHViNGUwIFx1Yzc5MFx1YzVmMFx1YzIxOCBOXHVjNzQwICgyPHN1cD5hPFwvc3VwPikoMzxzdXA+YjxcL3N1cD4pXHVjNzU4IFx1ZDU2OVx1YzczY1x1Yjg1YyBcdWIwOThcdWQwYzBcdWIwYmMgXHVjMjE4IFx1Yzc4OFx1YjJlNC4gXHVjNzc0XHViNTRjLCBcdWMxMWNcdWI4NWMgXHVjNTdkXHVjMjE4XC9cdWJjMzBcdWMyMTggXHVhZDAwXHVhY2M0XHVjNzc4IFx1YjQ1MCBcdWQ1NmRcdWM3NzQgXHVjNzg4XHVjNWI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IHNlcGFyYXRlZCBieSBhIHNpbmdsZSBzcGFjZS4gJmx0OzIgZXhwb25lbnQmZ3Q7IGlzIHRoZSBwb3dlciBvZiAyIGluIHRoZSB0ZXJtIGFuZCAmbHQ7MyBleHBvbmVudCZndDsgaXMgdGhlIHBvd2VyIG9mIDMgaW4gdGhlIHRlcm0uJm5ic3A7PFwvcD5cclxuIiwiaGludCI6IiIsIm9yaWdpbmFsIjoiMSIsInByb2JsZW1fbGFuZ19jb2RlIjoiXHVjNjAxXHVjNWI0In1d

출처

ACM-ICPC > Regionals > North America > Greater New York Region > 2006 Greater New York Programming Contest H번

  • 문제를 번역한 사람: baekjoon
  • 문제의 오타를 찾은 사람: doju