Tushengjia @ 2023-12-21 20:49:57
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,m;
cin>>n;
for(;;)
{
if(n==1)
{
cout<<"End"<<endl;
break;
}
if(n%2==0)
{
cout<<n<<"/2=";
n=n/2;
cout<<n<<endl;
}
else if(n%2==1)
{
cout<<n<<"*3+1=";
n=n*3+1;
cout<<n<<endl;
}
}
return 0;
}
** 这咋超时了?
by _____QWQ_____ @ 2023-12-21 21:09:18
正常来讲int可以 @Tushengjia
by _____QWQ_____ @ 2023-12-21 21:13:11
可以随便造个数据试试的,比如(1234567890)
by Wyf32627 @ 2023-12-21 21:15:32
@Tushengjia 现在还TLE吗?
by Tushengjia @ 2023-12-22 19:52:04
@Frank_world 是的
by Tushengjia @ 2023-12-22 19:56:35
@__QAQ__ 试了一下,算出来是负数
by Tushengjia @ 2023-12-22 20:04:22
@xiaoshumiao @__QAQ__ @Frank_world 谢谢,改成long long就可以了