d751. 10049 - Self­describing Sequence
標籤 :
通過比率 : 59人/65人 ( 91% ) [非即時]
評分方式:
Tolerant

最近更新 : 2015-08-28 14:03

內容

Solomon Golomb's self­describing sequence <f(1), f(2), f(3), ...> is the only non­decreasing sequence of positive integers with the property that it contains exactly f(k) occurrences of k for each k. A few moments thought reveals that the sequence must begin as follows:

 


In this problem you are expected to write a program that calculates the value of f(n) given the value of n.

輸入說明

The input may contain multiple test cases. Each test case occupies a separate line and contains an integer n ( 1 <= n <= 2,000,000,000 ). The input terminates with a test case containing a value 0 for n and this case must not be processed.

輸出說明

For each test case in the input output the value of f(n) on a separate line.

範例輸入 #1
100
9999
123456
1000000000
0
範例輸出 #1
21
356
1684
438744
測資資訊:
記憶體限制: 512 MB
公開 測資點#0 (100%): 3.0s , <10M
提示 :
標籤:
出處:
UVa10049 [管理者: david942j (文旋) ]

本題狀況 本題討論 排行

編號 身分 題目 主題 人氣 發表日期
沒有發現任何「解題報告」