【bzoj1666】 [Usaco2006 Oct]Another Cow Number Game 奶牛的数字游戏

来源:互联网 发布:python数据挖掘实战pdf 编辑:程序博客网 时间:2024/06/08 10:36
 题目传送门
题解 : 懒得写了 xjb模拟
#include<bits/stdc++.h>#define ll long longconst int INF = 0x7fffffff;const double eps = 1e-5;using namespace std;int read(){int x = 0 , f = 1; char ch = getchar();while(ch<'0'||ch>'9') {if(ch=='-')f*=-1;ch=getchar();}while(ch>='0'&&ch<='9'){x=x*10+(ch-'0');ch=getchar();}return x * f;}int n,ans;int main(){n = read();while( n ^ 1){++ans;if(n&1) n=n*3+1;else  n>>=1;}printf("%d",ans);return 0;}


阅读全文
0 0