UVA - 694 - The Collatz Sequence
来源:互联网 发布:淘宝店铺的图片 编辑:程序博客网 时间:2024/05/19 13:26
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=94&page=show_problem&problem=635
题意:
输入数字A,分段函数处理。水
#include <iostream>#include <stdio.h>using namespace std;int main(){long long num, A, L;long long iCase = 0;while ( 1 ){cin >>num >>L;A = num;if ( A < 0 && L < 0 ){break;} // end ifiCase++;long long nTerm = 0;while ( 1 ){if ( A > L ){break;} // end ifelse{nTerm++;if ( A == 1 ){break;} // end ifelse{if ( A%2 == 0 ){A = A/2;} // end ifelse{A = 3*A+1;} // end else} // end else} // end else} // end whilecout <<"Case " <<iCase <<": A = " <<num<<", limit = " <<L<<", number of terms = " << nTerm<<'\n';} // end whilereturn 0;}
0 0
- UVa 694 - The Collatz Sequence
- uva-694 - The Collatz Sequence
- UVa 694 The Collatz Sequence
- UVA 694 - The Collatz Sequence
- UVA 694 - The Collatz Sequence
- UVa 694 - The Collatz Sequence
- UVA - 694 - The Collatz Sequence
- UVa 694 - The Collatz Sequence
- UVa 694 The Collatz Sequence
- UVA 694 The Collatz Sequence
- UVA 694 The Collatz Sequence
- UVA 694 The Collatz Sequence
- UVA 694-The Collatz Sequence
- UVA - 694 The Collatz Sequence
- UVA - 694 The Collatz Sequence
- uva The Collatz Sequence
- UVa 694 The Collatz Sequence(序列)
- UVa 694 The Collatz Sequence (数论)
- QT生成DLL,调用DLL
- STL中的常用的vector,map,set,Sort用法
- 卡尔曼理论学习及公示推导
- 两分钟彻底让你明白Android Activity生命周期(图文)!
- HDU 2923 Einbahnstrasse
- UVA - 694 - The Collatz Sequence
- STL算法-交集,并集,差集,对称差
- maven pom 详解
- C++函数重载
- spring中前置通知与后置通知
- Cocos2D-x游戏开发之二十一:ScheduleUpdate 和ScheduleOne的用法
- ubuntu下NDK9交叉编译ffmpeg
- 隐藏Ubuntu引导,直接进入系统——变色龙引导Linux,Windows,Mac OS(苹果系统)攻略之二
- 音乐播放器源代码