7 条题解

  • 2
    @ 2022-10-18 16:59:12
    #include<stdio.h>
     
    int main()
    {
        int n;
        while(scanf("%d",&n)!=EOF)
        {
    		while(n!=1)
    		{
    			if(n%2!=0)
    			{
    				printf("%d*3+1=%d\n",n,n*3+1);
    				n=n*3+1;
    			}
    			else
    			{
    				printf("%d/2=%d\n",n,n/2);
    				n=n/2;
    			}
    		}
    		printf("End\n");
        }
        return 0;
    }
    
    • 1
      @ 2023-5-15 18:27:00

      #include< iosteam>

      #include<stdio.h>

      
      

      int main() { int n; while(scanf("%d",&n)!=EOF) { while(n!=1) { if(n%2!=0) { printf("%d3+1=%d\n",n,n3+1); n=n*3+1; } else { printf("%d/2=%d\n",n,n/2); n=n/2; } } printf("End\n"); } return 0; }

      • 1
        @ 2023-1-3 10:10:30
        #include<bits/stdc++.h>
        using namespace std;
        int n;
        int main()
        {
        	cin>>n;
        	while(n!=1)
        	{
        		if(n%2==0)
        		{
        			printf("%d/2=%d\n",n,n/2);
        			n/=2;
        		}
        		else
        		{
        			printf("%d*3+1=%d\n",n,n*3+1);
        			n=n*3+1;
        		}
        	}
        	printf("End");
        	return 0;
        }
        
        • 0
          @ 2024-12-13 17:56:21
          #include<iomanip>
          #include<cmath>
          using namespace std;
          int m,k,sum,n;
          int main()
          {
          	cin>>n;
          	while(n!=1)
          	{
          		if(n%2==0)
          		{
          			cout<<n<<"/2="<<n/2<<endl;
          			n/=2;
          		}
          			else if(n%2!=0)
          			{
          				cout<<n<<"*3+1="<<n*3+1<<endl;
          				n=3*n+1;
          			}
          	}
          	if(n==1)
          	{
          		cout<<"End";
          	}
          	return 0;
          }
          
          
          • 0
            @ 2022-10-18 16:57:35
            #include<iostream>
            #include<bits/stdc++.h>
            using namespace std;
            int main(){
            	long long a;
            	cin>>a;
            	while(a!=1){
            		if(a%2==0){
            			cout<<a<<"/2="<<a/2<<endl;
            			a=a/2;
            		}
            		else if(a%2!=0){
            			cout<<a<<"*3+1="<<3*a+1<<endl;
            			a=3*a+1;
            		}
            	}
            	if(a==1){
            		cout<<"End";
            		return 0;
            	}
            	cout<<"End"; 
            	return 0;
            }
            
            • -2
              @ 2022-10-18 16:57:50

              #include<iostream>

              #include<bits/stdc++.h>

              using namespace std;

              int main(){

              long long a;
              
              cin>>a;
              
              while(a!=1){
              
              	if(a%2==0){
              
              		cout<<a<<"/2="<<a/2<<endl;
              
              		a=a/2;
              
              	}
              
              	else if(a%2!=0){
              
              		cout<<a<<"*3+1="<<3*a+1<<endl;
              
              		a=3*a+1;
              
              	}
              
              }
              if(a==1){
              
              	cout<<"End";
              
              	return 0;
              
              }
              
              cout<<"End"; 
              
              return 0;
              

              }

              • -3
                @ 2021-10-29 19:53:46

                n=int(input()) c=0 while(n!=1): if(n%21): c=n*3+1 print("{:.0f}*3+1={:.0f}".format(n,c)) n=c elif(n%20): c=n/2 print("{:.0f}/2={:.0f}".format(n,c)) n=c print("End")

                • 1

                信息

                ID
                918
                时间
                1000ms
                内存
                128MiB
                难度
                5
                标签
                递交数
                430
                已通过
                161
                上传者