题解 | 卡拉兹函数

卡拉兹函数

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;
}

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务