为啥TLE
查看原帖
为啥TLE
1247040
V_HAPPY666楼主2024/3/9 22:24
#include <bits/stdc++.h>
using namespace std;

int main()
{
 	ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	//freopen("?.in","r",stdin);
	//freopen("?.out","w",stdout);
	int n;
	cin>>n;
	if(n==1)
	{
		cout<<"End";
		exit(0);
	}
	while(n!=1)
	{
		if(n%2!=0)
		{
			cout<<n<<"*3+1="<<n*3+1<<endl;
			n=n*3+1;
		}
		else
		{
			cout<<n<<"/2="<<n/2<<endl;
			n=n/2;
		}
	}
	cout<<"End";
	return 0;
}

2024/3/9 22:24
加载中...