19 条题解

  • 10
    @ 2024-3-17 9:58:18
    #include<bits/stdc++.h> 
    using namespace std; 
    int main(){ 
        int a,i; 
        double sum=0,sum1=0;
        cin>>a;
        while (a>1){
            if(a%2==0){
               a=a/2; 
               sum=sum+1;
            }
            else{
               a=3*a+1; 
               sum1=sum1+1;
            }
        }
        cout<<sum1+sum;
    }
    
    • 0
      @ 2025-4-2 13:46:42
      #include<bits/stdc++.h>
      using namespace std;
      int main(){
      	int m,n=2,i=0,sum=0;//意义不明的n和i
      	cin>>m;
      	while (m!=1){
      		if(m%2==0){
      			m=m/2;
      		}
      		else if(m%2==1){
      			m=3*m+1;
      		}
      		sum+=1;
      	}
      	cout<<sum<<endl;
      	return 0;
      } 
      
      
      • 0
        @ 2024-3-17 10:08:22

        #include<bits/stdc++.h> using namespace std; int main(){ int a,i; double sum=0,sum1=0; cin>>a; while (a>1){ if(a%2==0){ a=a/2; sum=sum+1; } else{ a=3*a+1; sum1=sum1+1; } } cout<<sum1+sum; }

        • -1
          @ 2025-3-30 11:18:20

          #include<bits/stdc++.h> using namespace std; int main(){ int a,i; double sum=0,sum1=0; cin>>a; while (a>1){ if(a%2==0){ a=a/2; sum=sum+1; } else{ a=3*a+1; sum1=sum1+1; } } cout<<sum1+sum; }

          • -1
            @ 2024-3-31 9:27:37
            #include<bits/stdc++.h> 
            using namespace std; 
            int main(){ 
                int a,i; 
                double sum=0,sum1=0;
                cin>>a;
                while (a>1){
                    if(a%2==0){
                       a=a/2; 
                       sum=sum+1;
                    }
                    else{
                       a=3*a+1; 
                       sum1=sum1+1;
                    }
                }
                cout<<sum1+sum;
            }
            
            • -1
              @ 2024-3-29 16:20:51
              #include<bits/stdc++.h> 
              using namespace std; 
              int main(){ 
                  int n,num=0; 
                  cin>>n; 
              	while(n!=1){
              	if(n%2==0) n = n/2;
              	else n = 3*n+1;
              	num++;
                  }
                  cout<<num;
                  return 0;
              }
              
              • -1
                @ 2024-3-24 9:16:57
                #include<bits/stdc++.h> 
                using namespace std; 
                int main(){ 
                    int a,i; 
                    double sum=0,sum1=0;
                    cin>>a;
                    while (a>1){
                        if(a%2==0){
                           a=a/2; 
                           sum=sum+1;
                        }
                        else{
                           a=3*a+1; 
                           sum1=sum1+1;
                        }
                    }
                    cout<<sum1+sum;
                }
                
                • -1
                  @ 2024-3-17 12:04:49

                  #include<bits/stdc++.h> using namespace std; int main(){ int n,d; double sum=0,sum1=0; cin>>n; while(n>1){ if(n%2==0){ n=n/2; sum=sum+1; d++; } else{ n=n*3+1; sum1=sum1+1; d++; } } cout<<sum+sum1; return 0; }

                  • -1
                    @ 2024-3-17 10:30:38
                    #include<bits/stdc++.h> 
                    using namespace std; 
                    int main(){ 
                        int a,i; 
                        double sum=0,sum1=0;
                        cin>>a;
                        while (a>1){
                            if(a%2==0){
                               a=a/2; 
                               sum=sum+1;
                            }
                            else{
                               a=3*a+1; 
                               sum1=sum1+1;
                            }
                        }
                        cout<<sum1+sum;
                    }
                    
                    • -1
                      @ 2024-3-17 10:30:19

                      #include<bits/stdc++.h> using namespace std; int main(){ int a,i; double sum=0,sum1=0; cin>>a; while (a>1){ if(a%2==0){ a=a/2; sum=sum+1; } else{ a=3*a+1; sum1=sum1+1; } } cout<<sum1+sum; }

                      • -1
                        @ 2024-3-17 10:28:53
                        #include<bits/stdc++.h> 
                        using namespace std; 
                        int main(){ 
                            int a,i; 
                            double sum=0,sum1=0;
                            cin>>a;
                            while (a>1){
                                if(a%2==0){
                                   a=a/2; 
                                   sum=sum+1;
                                }
                                else{
                                   a=3*a+1; 
                                   sum1=sum1+1;
                                }
                            }
                            cout<<sum1+sum;
                        }
                        
                        • -1
                          @ 2024-3-17 10:08:56

                          #include<bits/stdc++.h> using namespace std; int main(){ int a,i; double sum=0,sum1=0; cin>>a; while (a>1){ if(a%2==0){ a=a/2; sum=sum+1; } else{ a=3*a+1; sum1=sum1+1; } } cout<<sum1+sum; }

                          • -1
                            @ 2024-3-15 21:00:06
                            #include<bits/stdc++.h> 
                            using namespace std; 
                            int main(){ 
                                int a,i; 
                                double sum=0,sum1=0;
                                cin>>a;
                                while (a>1){
                                    if(a%2==0){
                                       a=a/2; 
                                       sum=sum+1;
                                    }
                                    else{
                                       a=3*a+1; 
                                       sum1=sum1+1;
                                    }
                                }
                                cout<<sum1+sum;
                            }
                            
                            • -2
                              @ 2024-3-23 11:12:31

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

                              • -2
                                @ 2024-3-22 16:52:42

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

                                • -2
                                  @ 2024-3-17 16:43:57

                                  #include<bits/stdc++.h> using namespace std; int main(){ int a,cnt=0; cin>>a; while(1!=a){ if(a%2==0) a=a/2; else a=a*3+1; cnt++;} cout<<cnt; }

                                  • -2
                                    @ 2024-3-17 10:11:36
                                    #include<bits/stdc++.h> 
                                    using namespace std; 
                                    int main(){ 
                                        int a,i; 
                                        double sum=0,sum1=0;
                                        cin>>a;
                                        while (a>1){
                                            if(a%2==0){
                                               a=a/2; 
                                               sum=sum+1;
                                            }
                                            else{
                                               a=3*a+1; 
                                               sum1=sum1+1;
                                            }
                                        }
                                        cout<<sum1+sum;
                                    }
                                    
                                    • -2
                                      @ 2024-3-17 10:10:01
                                      #include<bits/stdc++.h> 
                                      using namespace std; 
                                      int main(){ 
                                          int a,i; 
                                          double sum=0,sum1=0;
                                          cin>>a;
                                          while (a>1){
                                              if(a%2==0){
                                                 a=a/2; 
                                                 sum=sum+1;
                                              }
                                              else{
                                                 a=3*a+1; 
                                                 sum1=sum1+1;
                                              }
                                          }
                                          cout<<sum1+sum;
                                      }
                                      
                                      • -3
                                        @ 2024-3-17 10:28:30
                                        #include<bits/stdc++.h> 
                                        using namespace std; 
                                        int main(){ 
                                            int a,i; 
                                            double sum=0,sum1=0;
                                            cin>>a;
                                            while (a>1){
                                                if(a%2==0){
                                                   a=a/2; 
                                                   sum=sum+1;
                                                }
                                                else{
                                                   a=3*a+1; 
                                                   sum1=sum1+1;
                                                }
                                            }
                                            cout<<sum1+sum;
                                        }
                                        
                                        • 1

                                        信息

                                        ID
                                        2144
                                        时间
                                        1000ms
                                        内存
                                        256MiB
                                        难度
                                        2
                                        标签
                                        递交数
                                        592
                                        已通过
                                        336
                                        上传者