시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 21 9 8 57.143%

문제

길이가 무한대인 수열 A가 있다. A[N](N ≥ 1)은 N으로 시작하는 가장 작은 4의 배수이다. A[N]의 모든 자리수를 이어 붙이면 길이가 무한대인 문자열 S를 만들 수 있다. 척 노리스는 이 수열을 두 번이나 끝까지 써보았다.

S의 K번째 숫자를 구하는 프로그램을 작성하시오.

수열은 12, 20, 32, 4, 52, 60, ... 으로 시작하게 되며, S = "12203245260..."이 된다.

입력

입력은 여러 개의 테스트 케이스로 이루어져 있다. 각 테스트 케이스는 한 줄로 이루어져 있으며 양의 정수 K가 주어진다. (K <= 1015) 입력의 마지막 줄에는 0이 하나 주어진다. 

출력

각 테스트 케이스에 대해서, S의 K번째 자리수를 출력한다.

예제 입력 1

1
7
15
0

예제 출력 1

1
4
9
W3sicHJvYmxlbV9pZCI6IjE4MDciLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWNjOTkgXHViMTc4XHViOWFjXHVjMmE0IiwiZGVzY3JpcHRpb24iOiI8cD5cdWFlMzhcdWM3NzRcdWFjMDAgXHViYjM0XHVkNTVjXHViMzAwXHVjNzc4IFx1YzIxOFx1YzVmNCBBXHVhYzAwIFx1Yzc4OFx1YjJlNC4gQVtOXShOICZnZTsgMSlcdWM3NDAgTlx1YzczY1x1Yjg1YyBcdWMyZGNcdWM3OTFcdWQ1NThcdWIyOTQgXHVhYzAwXHVjN2E1IFx1Yzc5MVx1Yzc0MCA0XHVjNzU4IFx1YmMzMFx1YzIxOFx1Yzc3NFx1YjJlNC4gQVtOXVx1Yzc1OCBcdWJhYThcdWI0ZTAgXHVjNzkwXHViOWFjXHVjMjE4XHViOTdjIFx1Yzc3NFx1YzViNCBcdWJkOTlcdWM3NzRcdWJhNzQgXHVhZTM4XHVjNzc0XHVhYzAwIFx1YmIzNFx1ZDU1Y1x1YjMwMFx1Yzc3OCBcdWJiMzhcdWM3OTBcdWM1ZjQgU1x1Y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8gdGhpcyBmb3IgeW91IGluIGhpcyBzcGFyZSB0aW1lLjxcL3A+XHJcblxyXG48cD5XaGF0IGlzIHRoZSBLdGggZGlnaXQgaW4gUz88XC9wPlxyXG5cclxuPHA+U3BlY2lmaWNhbGx5LCBzZXF1ZW5jZSBiZWdpbnMgYXMgMTIsMjAsMzIsNCw1Miw2MCwuLi4sIHJlc3VsdGluZyBpbiBTPSZxdW90OzEyMjAzMjQ1MjYwLi4uJnF1b3Q7LjxcL3A+XHJcbiIsImlucHV0IjoiPHA+TnVtYmVyIG9mIGNhc2VzLCBlYWNoIGNhc2UgY29udGFpbnMgcG9zaXRpdmUgaW50ZWdlciBLIChLJmx0Oz0xMF4xNSkuIExhc3QgY2FzZSBpcyBmb2xsb3dlZCBieSB0aGUgbGluZSBjb250YWluaW5nIGEgc2luZ2xlIHplcm8uPFwvcD5cclxuXHJcbjxwPiZuYnNwOzxcL3A+XHJcbiIsIm91dHB1dCI6IjxwPkZvciBlYWNoIHRlc3QgY2FzZSwgcHJpbnQgdGhlIEt0aCBkaWdpdCBvZiBTIG9uIHNlcGFyYXRlIGxpbmUuPFwvcD5cclxuXHJcbjxwPiZuYnNwOzxcL3A+XHJcbiIsImhpbnQiOiIiLCJvcmlnaW5hbCI6IjEiLCJodG1sX3RpdGxlIjoiMCIsInByb2JsZW1fbGFuZ19jb2RlIjoiXHVjNjAxXHVjNWI0In1d

출처

ICPC > Regionals > North America > Rocky Mountain Regional > Alberta Collegiate Programming Contest > ACPC 2012 H번

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