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 xiaoshumiao @ 2023-12-21 20:53:30
@Tushengjia long long
by Tushengjia @ 2023-12-21 20:56:55
为啥啊
by Tushengjia @ 2023-12-21 20:57:41
不用longlong不行吗
by Tushengjia @ 2023-12-21 21:01:25
而且longlong怎么用啊?
by Tushengjia @ 2023-12-21 21:02:05
我不知道诶
by _____QWQ_____ @ 2023-12-21 21:02:15
@Tushengjia 在极限情况下会溢出int范围
by Tushengjia @ 2023-12-21 21:05:31
能给我讲一下吗?
by Tushengjia @ 2023-12-21 21:06:10
@__QAQ__
by xiaoshumiao @ 2023-12-21 21:07:44
@Tushengjia 因为他一路乘3加1上去可能会变得很大。至于为什么是TLE而不是WA我不知道。
by _____QWQ_____ @ 2023-12-21 21:08:52
好像是今年数据更新了但没标 @Tushengjia