cwcDaShuaiGe @ 2024-01-05 16:57:39
#include<bits/stdc++.h>
using namespace std;
int main(){
int 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";
return 0;
}
by ink_snow @ 2024-01-05 17:27:37
玩归玩,闹归闹,别拿long long开玩笑
by zhangshengzhe1 @ 2024-01-05 17:39:11
#include<iostream>
#include<cmath>
using namespace std;
int main(){
long long n;
cin>>n;
while(1){
if(n==1){
cout<<"End";
break;
}
else{
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;
}
}
}
return 0;
}
by huangzhixia @ 2024-01-05 17:43:18
@cwcDaShuaiGe 不开 long long 见祖宗。
by cwcDaShuaiGe @ 2024-01-07 20:39:04
谢谢大佬
by aiyouwei @ 2024-01-08 13:32:17
十年OI一场空,不开long long见祖宗
by cwcDaShuaiGe @ 2024-01-10 15:51:43
aiyouwei咋还是屎黄色的名字呀
by gubb @ 2024-08-08 13:50:20
#include <bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
if (n!=1){
do{
if(n%2==1){
cout<<n<<"*3+1="<<n*3+1<<endl;
n=n*3+1;
}
if (n%2==0){
cout<<n<<"/2="<<n/2<<endl;
n=n/2;
}
}while(n!=1);
//cout<<"End";
/*放在哪都行*/
}
cout<<"End";
return 0;
}