1666: [Usaco2006 Oct]Another Cow Number Game 奶牛的数字游戏
2016-11-14 17:51
543 查看
1666: [Usaco2006 Oct]Another Cow Number Game 奶牛的数字游戏
Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 763 Solved: 665
[Submit][Status][Discuss]
Description
奶牛们又在玩一种无聊的数字游戏。输得很郁闷的贝茜想请你写个程序来帮她在开局时预测结果。在游戏的开始,每头牛都会得到一个数N(1<=N<=1,000,000)。此时奶牛们的分数均为0。如果N是奇数,那么奶牛就会把它乘以3后再加1。如果N是偶数,那么这个数就会被除以2。数字每变动一次,这头奶牛就得到1分。当N的值等于1时,游戏结束,此时的分数就是这头奶牛在这局游戏中的最终得分。以下是N的初始值为5时,一局游戏的完整过程: N 操作后所得数 注释 总分 5 16 3*5+1 1 16 8 16/2 2 8 4 8/2 3 4 2 4/2 4 2 1 2/2 5 这头奶牛的最终得分是5。
Input
* 第1行: 一个正整数,NOutput
* 第1行: 输出一个正整数N,即奶牛在这局游戏中的最终得分Sample Input
112Sample Output
20HINT
Source
Gold不知道模拟为何会是gold题。。。。
附代码:
#include<iostream> #include<algorithm> #include<cstdlib> #include<cstdio> using namespace std; int x,ans; int main() { scanf("%d",&x); while(x!=1) { if(x&1)x=x*3+1; else x>>=1; ans++; }printf("%d\n",ans); }
相关文章推荐
- BZOJ 1666: [Usaco2006 Oct]Another Cow Number Game 奶牛的数字游戏
- 【bzoj1666】 [Usaco2006 Oct]Another Cow Number Game 奶牛的数字游戏
- BZOJ1666: [Usaco2006 Oct]Another Cow Number Game 奶牛的数字游戏
- 1666: [Usaco2006 Oct]Another Cow Number Game 奶牛的数字游戏
- 【BZOJ】1666 [Usaco2006 Oct]Another Cow Number Game 奶牛的数字游戏
- 【BZOJ】1666: [Usaco2006 Oct]Another Cow Number Game 奶牛的数字游戏(刷水严重)
- 1666: [Usaco2006 Oct]Another Cow Number Game 奶牛的数字游戏
- bzoj:1666: [Usaco2006 Oct]Another Cow Number Game 奶牛的数字游戏
- bzoj 1666: [Usaco2006 Oct]Another Cow Number Game 奶牛的数字游戏
- bzoj1666[Usaco2006 Oct]Another Cow Number Game 奶牛的数字游戏
- bzoj1666[Usaco2006 Oct]Another Cow Number Game 奶牛的数字游戏
- bzoj 1666: [Usaco2006 Oct]Another Cow Number Game 奶牛的数字游戏【模拟】
- [Usaco2006 Oct]Another Cow Number Game 奶牛的数字游戏 记忆化搜索
- BZOJ_P1666 [Usaco2006 Oct]Another Cow Number Game 奶牛的数字游戏(hhhhhh)
- [bzoj3404] [Usaco2009 Open]Cow Digit Game又见数字游戏
- bzoj3404 [Usaco2009 Open]Cow Digit Game又见数字游戏
- [BZOJ3404][Usaco2009 Open]Cow Digit Game又见数字游戏
- bzoj3404 [Usaco2009 Open]Cow Digit Game又见数字游戏
- 【博弈论】【SG函数】bzoj3404 [Usaco2009 Open]Cow Digit Game又见数字游戏
- 3404: [Usaco2009 Open]Cow Digit Game又见数字游戏