题解 | 卡拉兹函数
卡拉兹函数
https://www.nowcoder.com/practice/fd497366b6a54ce18698f853cc1bd503
#include <bits/stdc++.h>
#include <iomanip>
#include <string>
using namespace std;
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin>>n;
if(n%2==0){
cout<<n/2;
}
else{
cout<<3*n+1;
}
return 0;
}
查看20道真题和解析