E D R , A S I H C RSS

Self-describing Sequence

›ฌธ๊ธฐ
----
ธ๊ธฐ„:C(A,B,C), „ฑ๊ณตฅ :†’Œ(‚ฎŒ,†ต,†’Œ),  ˆฒจ:2(1~4)

About Self-describingSequence

†”กœฌ ๊ณจกฑ(Solomon Golomb)˜ ž๊ธฐ๊ธฐˆ  ˆ˜— <f(1), f(2), f(3), ... >€ ๊ฐ k— Œ€• kผŠ” ˆซž๊ฐ€  •™••˜๊ฒŒ f(k)ฒˆ “ฑžฅ•˜Š” †„ฑ„ ๊ฐ€€Š” –‘˜  •ˆ˜กœ ๊ตฌ„ฑœ œ ผ•œ น„๊ฐ†Œˆ˜—‹ค.  ˆ˜—˜ •ž €ถ„„ ƒ๊ฐ• ‹คŒ๊ณผ ๊ฐ™€ ‹ผŠ” ๊ฒƒ„ •Œ ˆ˜ žˆ‹ค.
http://online-judge.uva.es/p/v100/10049img2.gif
––ค ๊ฐ’ n ฃผ–กŒ„ •Œ f(n)˜ ๊ฐ’„ ๊ณ„‚ฐ•˜Š” ”„กœ๊ทธžจ„ งŒ“ค–••œ‹ค.

Input

—ฌŸฌ ๊ฐœ˜ …ŒŠคŠธ €Šค๊ฐ€ ž… ฅ  ˆ˜ žˆ‹ค. ๊ฐ ค„งˆ‹ค •˜‚˜”ฉ˜  •ˆ˜ n ž… ฅ˜ฉฐ,  •ˆ˜ •œ ๊ฐœ๊ฐ€ •˜‚˜˜ …ŒŠคŠธ €Šคฅผ ฃฌ‹ค(1 โ‰ค n โ‰ค 2,000,000,000). n 0ธ …ŒŠคŠธ €Šค๊ฐ€ ž… ฅ˜ ž… ฅ ข…ฃŒ˜ฉฐ, ๊ทธ €ŠคŠ” ฒ˜ฆฌ•˜€ •ŠŠ”‹ค.

Output

๊ฐ …ŒŠคŠธ €Šค— Œ€• •œ ค„— •˜‚˜”ฉ f(n) ๊ฐ’„ ถœ ฅ•œ‹ค.

Sample Input

{{| 100
9999
123456
1000000000
0 |}}

Sample Output

{{| 21
356
1684
438744 |}}

’€

ž‘„ฑž ‚ฌšฉ–ธ– ๊ฐœฐœ‹œ๊ฐ„ ฝ”“œ
ฌธฐฝ C++ 2‹œ๊ฐ„ Self-describingSequence/ฌธฐฝ
™žฌ„  Java 2‹œ๊ฐ„ Self-describingSequence/™žฌ„ 
1002 Python 1‹œ๊ฐ„ 40ถ„ Self-describingSequence/1002
shon matlab 1ฐจ : 1‹œ๊ฐ„ 10ถ„, 2ฐจ : 3‹œ๊ฐ„ Self-describingSequence/shon
กฐ˜„ƒœ C++ ? Self-describingSequence/กฐ˜„ƒœ

Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:28:00
Processing time 0.0135 sec