若是凉夜已成梦

青春里 总有些事情要努力去做 总有些梦想要拼命去追。


  • 运维

  • 前端

  • 编程

  • 随笔

  • hust-oj

1540: Self-describing Sequence

发表于 2017-10-06   |   分类于 HUSTOJ   |   阅读次数 1,315

题目描述

Self-describing Sequence

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 moment's thought reveals that the sequence must begin as follows:

n 1 2 3 4 5 6 7 8 9 10 11 12
f (n) 1 2 2 3 3 4 4 4 5 5 5 6

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

样例输入

100
9999
123456
1000000000
0


样例输出

21
356
1684
438744


参考代码

暂无

解析

暂无

hustoj

发表评论 取消回复

邮箱地址不会被公开。 必填项已用*标注

*
*


hoxis wechat
著作权归作者所有
站点更新说明
  • 文章目录
  • 站点概览
若是凉夜已成梦

若是凉夜已成梦

青春里 总有些事情要努力去做 总有些梦想要拼命去追。

1904 日志
6 分类
12 标签
RSS
weibo github twitter facebook

友情链接

Dreams孤独患者 Skip 原站点
© 2017 若是凉夜已成梦
Powered by WordPress | 已运行
Theme By NexT.Mist