help!

B2077 角谷猜想

guomu @ 2024-10-20 15:46:16

#include<bits/stdc++.h>
using namespace std;
long long n;
int main(){
    cin>>n;
    while(n!=1){
        if(n&1){
            printf("%d*3+1=%d\n",n,n*3+1);
            n=n*3+1;
        }else{
            printf("%d/2=%d\n",n,n/2);
            n/=2;
        }
    }
    cout<<"End";
    return 0;
}

by tzhengqing @ 2024-10-20 15:49:58

#include<bits/stdc++.h>
using namespace std;
long long n;
int main(){
    cin>>n;
    while(n!=1){
        if(n&1ll){
            printf("%lld*3+1=%lld\n",n,n*3+1ll);
            n=n*3+1ll;
        }else{
            printf("%lld/2=%lld\n",n,n/2);
            n/=2;
        }
    }
    cout<<"End";
    return 0;
}

by guomu @ 2024-10-20 15:54:07

三克油


|