시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 128 MB249857.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
W3sicHJvYmxlbV9pZCI6IjE4MDciLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWNjOTkgXHViMTc4XHViOWFjXHVjMmE0IiwiZGVzY3JpcHRpb24iOiI8cD5cdWFlMzhcdWM3NzRcdWFjMDAgXHViYjM0XHVkNTVjXHViMzAwXHVjNzc4IFx1YzIxOFx1YzVmNCBBXHVhYzAwIFx1Yzc4OFx1YjJlNC4gQVtOXShOICZnZTsgMSlcdWM3NDAgTlx1YzczY1x1Yjg1YyBcdWMyZGNcdWM3OTFcdWQ1NThcdWIyOTQgXHVhYzAwXHVjN2E1IFx1Yzc5MVx1Yzc0MCA0XHVjNzU4IFx1YmMzMFx1YzIxOFx1Yzc3NFx1YjJlNC4gQVtOXVx1Yzc1OCBcdWJhYThcdWI0ZTAgXHVjNzkwXHViOWFjXHVjMjE4XHViOTdjIFx1Yzc3NFx1YzViNCBcdWJkOTlcdWM3NzRcdWJhNzQgXHVhZTM4XHVjNzc0XHVhYzAwIFx1YmIzNFx1ZDU1Y1x1YjMwMFx1Yzc3OCBcdWJiMzhcdWM3OTBcdWM1ZjQgU1x1Yjk3YyBcd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3UgaW4gaGlzIHNwYXJlIHRpbWUuPFwvcD5cclxuXHJcbjxwPldoYXQgaXMgdGhlIEt0aCBkaWdpdCBpbiBTPzxcL3A+XHJcblxyXG48cD5TcGVjaWZpY2FsbHksIHNlcXVlbmNlIGJlZ2lucyBhcyAxMiwyMCwzMiw0LDUyLDYwLC4uLiwgcmVzdWx0aW5nIGluIFM9JnF1b3Q7MTIyMDMyNDUyNjAuLi4mcXVvdDsuPFwvcD5cclxuIiwiaW5wdXQiOiI8cD5OdW1iZXIgb2YgY2FzZXMsIGVhY2ggY2FzZSBjb250YWlucyBwb3NpdGl2ZSBpbnRlZ2VyIEsgKEsmbHQ7PTEwXjE1KS4gTGFzdCBjYXNlIGlzIGZvbGxvd2VkIGJ5IHRoZSBsaW5lIGNvbnRhaW5pbmcgYSBzaW5nbGUgemVyby48XC9wPlxyXG5cclxuPHA+Jm5ic3A7PFwvcD5cclxuIiwib3V0cHV0IjoiPHA+Rm9yIGVhY2ggdGVzdCBjYXNlLCBwcmludCB0aGUgS3RoIGRpZ2l0IG9mIFMgb24gc2VwYXJhdGUgbGluZS48XC9wPlxyXG5cclxuPHA+Jm5ic3A7PFwvcD5cclxuIiwiaGludCI6IiIsIm9yaWdpbmFsIjoiMSIsImh0bWxfdGl0bGUiOiIwIiwicHJvYmxlbV9sYW5nX3Rjb2RlIjoiRW5nbGlzaCJ9XQ==

출처

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

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