wikioi p3038 3n+1问题
2013-08-24 12:13
190 查看
#include<stdio.h> #include<iostream> #include<memory.h> using namespace std; int t,n; const int MAX_N = 50001; int f(int t,int deep) { if (t==1) return deep; if (t%2==0) return f(t/2,deep+1); else return f(3*t+1,deep+1); } int main() { int i; scanf("%d",&t); for (i=1;i<=t;i++) { scanf("%d",&n); printf("%d\n",f(n,0)); } return 0; }
相关文章推荐
- UVA 100 - The 3n+1 problem (3n+1 问题)
- 3n+1数列问题
- [没分] Tyvj-Begin P1039 Begin2 – Unit 1 - 3n+1问题
- HDU 1032(3n+1问题)
- 3n+1问题
- 1032 3n+1问题
- sdut acm 3n+1数列问题
- 3n+1数列问题
- 3n+1问题
- 3n+1问题
- 3n+1问题
- ACM 3n+1问题
- 3n+1问题
- UVA 100 && HDU 1032 The 3n+1问题 (扑街题)
- hdoj1032 3n+1问题
- POJ 1207 3n+1问题
- [WikiOI] 2.6.3 3n+1问题
- 3n+1问题 用c语言实现
- CODE[VS]_3038 3n+1问题
- 3n+1问题