694 - The Collatz Sequence
来源:互联网 发布:产品进入淘宝首页 编辑:程序博客网 时间:2024/05/18 17:57
#include<stdio.h>
int collatz( long long m,long long n,intcount)
{
count++;
if(m==1) return count;
if(m>n) return--count;
if(m%2==0)
collatz(m/2,n,count);
else
collatz(m*3+1,n,count);
}
int main()
{
long long m,n;
int i=0,count=0;
while(1)
{
i++;
scanf("%lld%lld",&m,&n);
if(m<0&&n<0)break;
printf("Case %d: A = %lld, limit = %lld,",i,m,n);
printf("number of terms =%d\n",collatz(m,n,count));
}
return 0;
}
uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=635
0 0
- 694 - The Collatz Sequence
- 694 - The Collatz Sequence
- 694 - The Collatz Sequence
- 694 - The Collatz Sequence
- 694 - The Collatz Sequence
- 694 - The Collatz Sequence
- 694 - The Collatz Sequence
- 694 - The Collatz Sequence
- uvaoj 694 - The Collatz Sequence
- UVa 694 - The Collatz Sequence
- uva-694 - The Collatz Sequence
- UVaOJ 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
- 从最大似然到EM算法浅解
- 490 - Rotating Sentences
- 445 - Marvelous Mazes
- 488 - Triangle Wave
- 489 - Hangman Judge
- 694 - The Collatz Sequence
- C# ASP.NET GridView导出EXCEL。
- Linux Input子系统--设备的注册和打开
- 457 - Linear Cellular Automata
- 401 - Palindromes
- 10010 - Where's Waldorf?
- 10361 - Automatic Poetry
- 《jQuery基础教程》4th 笔记- 选择元素
- 537 - Artificial Intelligence?