算法竞赛入门经典 正整数序列

来源:互联网 发布:九州园艺三角梅淘宝店 编辑:程序博客网 时间:2024/05/18 03:43

算法竞赛入门经典 正整数序列

/*Name: 正整数序列 Copyright: 刘汝佳 Author: Analyst Date: 01/03/14 12:10Description: dev-cpp 5.5.3*/#include <stdio.h>int f(int n){return n == 1 ? 1 : f(n/2)+1;  // n/2折半砍 }int main(){int n;while (scanf("%d", &n) == 1)printf("%d\n", f(n));return 0;} 
ps:

自己笔画一下,得出对半折最快。

0 0
原创粉丝点击