为什么四个AC,两个TLE?

B2077 角谷猜想

wyq1231 @ 2023-08-26 15:29:24

这个代码错哪儿了?

#include<bits/stdc++.h>
using namespace std;
int n;
int main(){
    cin>>n;
    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;
}

蒟蒻求助!!!


by gjc1108 @ 2023-08-26 15:36:38

@wyq1231

开long long


by wyq1231 @ 2023-08-26 15:42:21

@gjc1108 蟹蟹dalao!


by wyq1231 @ 2023-08-26 15:43:38

过了


by denghuolanshan_1004 @ 2023-09-12 14:47:32

爹!


by Xiong_xhrxhr @ 2023-11-29 21:32:14

"不开long long见祖宗"!!!


|