为什么错了

B2077 角谷猜想

czh1437 @ 2023-08-21 10:43:16

long long有了

样例过了

为什么才25!!!

#include<bits/stdc++.h> 
using namespace std;

int main(){
    long long n,sum=0;
    cin>>n;
    if(n!=1){
    sum=n*3+1;
    cout<<n<<"*3+1="<<sum<<endl;
    while(sum!=1){
        cout<<sum;
        sum=sum/2;
        cout<<"/2="<<sum<<endl;
    }
    cout<<"End"<<endl;

    }else cout<<"End"<<endl;
    return 0;
}

by ZGSZ_AviationLover @ 2023-08-21 10:44:51

#include<bits/stdc++.h>
using namespace std;
int n;
int main(){
    cin>>n;
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    while(n!=1){//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";//结尾输出End
    return 0;
}

@czh1437


by ZGSZ_AviationLover @ 2023-08-21 10:45:33

@czh1437 int即可


by czh1437 @ 2023-08-21 10:46:51

@tigerwang
Thank you


|