시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 15 8 7 70.000%

문제

길이가 무한대인 수열 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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vdSBpbiBoaXMgc3BhcmUgdGltZS48XC9wPlxyXG5cclxuPHA+V2hhdCBpcyB0aGUgS3RoIGRpZ2l0IGluIFM/PFwvcD5cclxuXHJcbjxwPlNwZWNpZmljYWxseSwgc2VxdWVuY2UgYmVnaW5zIGFzIDEyLDIwLDMyLDQsNTIsNjAsLi4uLCByZXN1bHRpbmcgaW4gUz0mcXVvdDsxMjIwMzI0NTI2MC4uLiZxdW90Oy48XC9wPlxyXG4iLCJpbnB1dCI6IjxwPk51bWJlciBvZiBjYXNlcywgZWFjaCBjYXNlIGNvbnRhaW5zIHBvc2l0aXZlIGludGVnZXIgSyAoSyZsdDs9MTBeMTUpLiBMYXN0IGNhc2UgaXMgZm9sbG93ZWQgYnkgdGhlIGxpbmUgY29udGFpbmluZyBhIHNpbmdsZSB6ZXJvLjxcL3A+XHJcblxyXG48cD4mbmJzcDs8XC9wPlxyXG4iLCJvdXRwdXQiOiI8cD5Gb3IgZWFjaCB0ZXN0IGNhc2UsIHByaW50IHRoZSBLdGggZGlnaXQgb2YgUyBvbiBzZXBhcmF0ZSBsaW5lLjxcL3A+XHJcblxyXG48cD4mbmJzcDs8XC9wPlxyXG4iLCJoaW50IjoiIiwib3JpZ2luYWwiOiIxIiwicHJvYmxlbV9sYW5nX2NvZGUiOiJcdWM2MDFcdWM1YjQifV0=

출처

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

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