4 条题解

  • 1
    @ 2026-7-7 16:14:05
    #include <bits/stdc++.h>
    using namespace std;
    
    int main() {
    	int a;
    	cin >> a;
    	for (; a > 1;) {
    		if (a % 2 != 0) {
    			cout << a << "*3+1=" << a * 3 + 1 << endl;
    			a = a * 3 + 1;
    		} else {
    			cout << a << "/2=" << a / 2 << endl;
    			a = a / 2;
    		}
    	}
    	cout << "End";
    	return 0;
    }
    
    
    
    • 0
      @ 2026-6-9 22:27:02
      #include<bits/stdc++.h> 
      using namespace std;
       int main(){
          long long n;
          cin >> n;
          while (n != 1) {
              if (n % 2 == 1) {
                  cout << n << "*3+1=" << n * 3 + 1 << endl;
                  n = n * 3 + 1;
              } else {
                  cout << n << "/2=" << n / 2 << endl;
                  n = n / 2;
              }
          }
          cout << "End" << endl;
              return 0;
               }
      
      
      • -1
        @ 2026-6-12 20:37:33

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

        int main() { int N; cin >> N; while (N != 1) { if (N % 2 == 0) { cout << N << "/2=" << N / 2 << endl; N /= 2;

        	} else {
        		cout << N << "*3+1=" << N * 3 + 1 << endl;
        
        		N = N * 3 + 1;
        
        	}
        
        }
        cout << "End";
        
        return 0;
        

        }

        • -1
          @ 2026-5-31 21:07:01

          #include<bits/stdc++.h> using namespace std; int main(){ int n; cin>>n; while(n!=1){ if(n%2==0){ cout<<n<<"/2="<<n/2<<endl; }else{ cout<<n<<"3+1="<<endl; n=n3+1; } return 0; }

          • 1

          信息

          ID
          30965
          时间
          1000ms
          内存
          256MiB
          难度
          4
          标签
          (无)
          递交数
          46
          已通过
          21
          上传者