HDU 1032 水题
2011-08-01 08:14
337 查看
/*
* Author:lonelycatcher
* problem:heu 1032
* type:纯水题
*/
#include <iostream>
#include<stdio.h>
#include<string.h>
#include<string.h>
using namespace std;
int fun(int x)
{
int i=1;
while(x!=1)
{
if(x&1)
{
x=3*x+1;
}else
{
x=x>>1;
}
i++;
}
return i;
}
int main()
{
setbuf(stdout,NULL);
int left,right,max,i,j;
while(scanf("%d %d",&left,&right)!=EOF)
{
max=0;
if(left<right)
{
for(i=left;i<=right;i++)
{
int sum=fun(i);
if(sum>max)
{
max=sum;
}
}
}
else
{
for(i=right;i<=left;i++)
{
int f=fun(i);
if(f>max)max=f;
}
}
printf("%d %d %d\n",left,right,max);
}
return 0;
}
* Author:lonelycatcher
* problem:heu 1032
* type:纯水题
*/
#include <iostream>
#include<stdio.h>
#include<string.h>
#include<string.h>
using namespace std;
int fun(int x)
{
int i=1;
while(x!=1)
{
if(x&1)
{
x=3*x+1;
}else
{
x=x>>1;
}
i++;
}
return i;
}
int main()
{
setbuf(stdout,NULL);
int left,right,max,i,j;
while(scanf("%d %d",&left,&right)!=EOF)
{
max=0;
if(left<right)
{
for(i=left;i<=right;i++)
{
int sum=fun(i);
if(sum>max)
{
max=sum;
}
}
}
else
{
for(i=right;i<=left;i++)
{
int f=fun(i);
if(f>max)max=f;
}
}
printf("%d %d %d\n",left,right,max);
}
return 0;
}
相关文章推荐
- HDU 1032 The 3n + 1 problem 【水题】
- hdu 1032 The 3n + 1 problem(水题)
- HDU 1032 The 3n + 1 problem (水题)
- hdu 1032 水题也wrong 两次(于是乎更有刷水题的必要了)
- HDU-1032 The 3n+1 problem 模拟问题(水题)
- HDU 1032(水题)
- HDU-1032-The 3n + 1 problem(C++&学英语&水题)
- HDU 1032 The 3n + 1 problem(水题)
- hdu水题十道,提高鸟语能力~~ 1032 1029 1033 1036 1037 1038 1039 1047 1856 1060 1061
- HDU1032-The 3n + 1 problem-水题压惊
- hdu1570(水题)
- HDU - 4821(95/600)字符串水题
- HDU 5494(水题)
- HDU 水题(基础题)题目分类
- [水题]hdu 2084
- HDU 3215 The first place of 2^n (数论-水题)
- hdu 1005:Number Sequence(水题)
- hdu 5660 jrMz and angles(水题)
- HDU1032 The 3n + 1 problem
- HDU 6140 Hybrid Crystals【阅读题】【水题】