您的位置:首页 > 其它

hdu1032(水吗?)

2016-01-15 00:00 295 查看
http://acm.hdu.edu.cn/showproblem.php?pid=1032





View Code

#include
"
iostream
"

using

namespace
std;

int
i,j,Max
=
0
;

int
fun(
int
x,
int
y)
{

for
(i
=
x; i
<=
y; i
++
)
{

int
count
=
1
;

int
xx
=
i;

while
(xx
!=
1
)
{

if
(xx
%
2
!=
0
) xx
=
3
*
xx
+
1
;

else
xx
=
xx
/
2
;
count
++
;

}

if
(count
>
Max) Max
=
count;
}

return
Max;
}

int
main()
{

int
N,M;

while
(scanf(
"
%d %d
"
,
&
N,
&
M)
!=
EOF)
{

Max
=
0
;

if
(N
>
M)
{

int
temp
=
N;
N
=
M;
M
=
temp;
printf(
"
%d %d %d\n
"
,M, N,fun(N,M));
}

else
printf(
"
%d %d %d\n
"
,N,M,fun(N,M));

}

return

0
;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: