시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 244 50 41 22.778%

문제

x가 정수 b의 제곱(x = b2)으로 나타낼 수 있으면 x를 완전 제곱수라고 한다. 또, x를 정수 b의 세제곱(x = b3)으로 나타낼 수 있으면 x를 완전 세제곱수라고 한다. 즉, x를 b의 p제곱(x = bp)으로 나타낼 수 있으면, x를 완전 p제곱수라고 한다.

x가 주어졌을 때, 가장 큰 p를 찾는 프로그램을 작성하시오.

입력

테스트 케이스는 정수 x를 포함하는 한 줄로 이루어져 있다. x는 절댓값이 2보다 크거나 같고, C,C++,Java에서 32비트 int 범위 안에 있다. 마지막 테스트 케이스 다음 줄에는 0이 있다.

출력

각각의 테스트 케이스에 대해서, x가 완전 p제곱수 일 때, 가장 큰 정수 p를 출력한다.

예제 입력 1

17
1073741824
25
0

예제 출력 1

1
30
2
W3sicHJvYmxlbV9pZCI6IjQzMjAiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWM2NDRcdWM4MDQgUFx1YzgxY1x1YWNmMVx1YzIxOCIsImRlc2NyaXB0aW9uIjoiPHA+XHJcblx0eFx1YWMwMCBcdWM4MTVcdWMyMTggYlx1Yzc1OCBcdWM4MWNcdWFjZjEoeCA9IGI8c3VwPjI8XC9zdXA+KVx1YzczY1x1Yjg1YyBcdWIwOThcdWQwYzBcdWIwYmMgXHVjMjE4IFx1Yzc4OFx1YzczY1x1YmE3NCB4XHViOTdjIFx1YzY0NFx1YzgwNCBcdWM4MWNcdWFjZjFcdWMyMThcdWI3N2NcdWFjZTAgXHVkNTVjXHViMmU0LiBcdWI2MTAsIHhcdWI5N2MgXHVjODE1XHVjMjE4IGJcdWM3NTggXHVjMTM4XHVjODFjXHVhY2YxKHggPSBiPHN1cD4zPFwvc3VwPilcdWM3M2NcdWI4NWMgXHViMDk4XHVkMGMwXHViMGJjIFx1YzIxOCBcdWM3ODhcdWM3M2NcdWJhNzQgeFx1Yjk3YyBcdWM2NDRcdWM4MDQ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vd2VyLjxcL3A+XHJcbiIsImlucHV0IjoiPHA+RWFjaCB0ZXN0IGNhc2UgaXMgZ2l2ZW4gYnkgYSBsaW5lIG9mIGlucHV0IGNvbnRhaW5pbmcgeC4gVGhlIHZhbHVlIG9mIHggd2lsbCBoYXZlIG1hZ25pdHVkZSBhdCBsZWFzdCAyIGFuZCBiZSB3aXRoaW4gdGhlIHJhbmdlIG9mIGEgKDMyLWJpdCkgaW50IGluIEMsIEMrKywgYW5kIEphdmEuIEEgbGluZSBjb250YWluaW5nIDAgZm9sbG93cyB0aGUgbGFzdCB0ZXN0IGNhc2UuPFwvcD5cclxuIiwib3V0cHV0IjoiPHA+Rm9yIGVhY2ggdGVzdCBjYXNlLCBvdXRwdXQgYSBsaW5lIGdpdmluZyB0aGUgbGFyZ2VzdCBpbnRlZ2VyIHAgc3VjaCB0aGF0IHggaXMgYSBwZXJmZWN0IHB0aCBwb3dlci48XC9wPlxyXG4iLCJoaW50IjoiIiwib3JpZ2luYWwiOiIxIiwicHJvYmxlbV9sYW5nX2NvZGUiOiJcdWM2MDFcdWM1YjQifV0=

출처

Contest > Waterloo's local Programming Contests > 31 January, 2004 E번

  • 잘못된 조건을 찾은 사람: august14
  • 문제를 번역한 사람: baekjoon