시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 256 MB 323 64 46 20.909%

문제

사람의 손가락은 10개이다. 따라서, 우리가 사용하는 숫자 체계는 10진법이다. 257이 의미하는 것은 2×102 + 5×101 + 7×100이다. 십진법의 각 자리는 0...9 구간에 포함된다.

10진법 말고 주로 사용하는 진법은 2진법, 8진법, 16진법이다. 이 진법은 컴퓨터에서 사용하거나, 다른 사람에게 큰 인상을 주기 위해서 사용한다. b진법의 각 자리는 0...b-1 구간에 포함된다. 또 각 자리를 오른쪽부터 읽었을 때, 곱해야 하는 수는 b의 다음 제곱이다.

에를 들어, 10진법에서 9는 다음과 같이 작성할 수 있다.

16진법으로는 9

8진법으로는 11 (1×81 + 1×80 = 9)

2진법으로는 1001 (1×23 + 0×22 + 0×21 + 1×20 = 9)

9는 위의 세가지 진법에서 모두 팰린드롬이다. 팰린드롬이란, 순서를 반대로 했을 때, 원래 순서와 같은 수열을 의미한다. 영단어에서 팰린드롬은 "dad", "mom", "racecar"가 있다. 9, 11, 1001과 같은 숫자도 팰린드롬이다.

10진법 숫자 X가 주어졌을 때, b진법으로 나타냈을 때, 팰린드롬인 것의 개수를 구하는 프로그램을 작성하시오. (2 ≤ b < X)

입력

첫째 줄에 X가 주어진다. (2 ≤ X ≤ 1,000,000,000)

출력

X를 b진법으로 나타냈을 때, 팰린드롬인 것을 모두 한 줄에 하나씩 증가하는 순서대로 출력한다.

예제 입력 1

9

예제 출력 1

2
8
W3sicHJvYmxlbV9pZCI6IjY3NTciLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWQzMzBcdWI5YjBcdWI0ZGNcdWI4NmMgXHVjOWM0XHViYzk1IiwiZGVzY3JpcHRpb24iOiI8cD5cdWMwYWNcdWI3OGNcdWM3NTggXHVjMTkwXHVhYzAwXHViNzdkXHVjNzQwIDEwXHVhYzFjXHVjNzc0XHViMmU0LiBcdWI1MzBcdWI3N2NcdWMxMWMsIFx1YzZiMFx1YjlhY1x1YW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BYLCBhbmQgdGhhdCB0aGUgXHVmYjAxcnN0IHBvc3NpYmxlIHZhbGlkIGJhc2UgaXMgMi48XC9wPlxyXG4iLCJoaW50IjoiPHA+VGhlIG51bWJlciA5IHdhcyBzaG93biB0byBiZSBhIHBhbGluZHJvbWUgaW4gYmFzZS0yIGFuZCBiYXNlLTggaW4gdGhlIHByb2JsZW0gZGVzY3JpcHRpb24uIFRoZSBvdGhlciBiYXNlcyBkbyBub3QgbGVhZCB0byBwYWxpbmRyb21lczogZm9yIGV4YW1wbGUsIGluIGJhc2UtMywgOSBpcyBleHByZXNzZWQgYXMgMTAwLCBhbmQgaW4gYmFzZS01LCA5IGlzIGV4cHJlc3NlZCBhcyAxNC48XC9wPlxyXG4iLCJvcmlnaW5hbCI6IjEiLCJwcm9ibGVtX2xhbmdfY29kZSI6Ilx1YzYwMVx1YzViNCJ9XQ==

출처

Olympiad > Canadian Computing Competition & Olympiad > 2013 > CCO 2013 1번

  • 잘못된 데이터를 찾은 사람: august14
  • 문제를 번역한 사람: baekjoon