PAT (Basic Level) Practise 1001
2015-04-18 10:30
375 查看
#include <stdio.h>
int main(int argc, char const *argv[])
{
int n;
int cnt = 0;
scanf("%d", &n);
while(n!=1){
if(n%2==0){
n/=2;
cnt++;
}
else{
n=(3*n+1)/2;
cnt++;
}
}
printf("%d", cnt);
return 0;
}
int main(int argc, char const *argv[])
{
int n;
int cnt = 0;
scanf("%d", &n);
while(n!=1){
if(n%2==0){
n/=2;
cnt++;
}
else{
n=(3*n+1)/2;
cnt++;
}
}
printf("%d", cnt);
return 0;
}
相关文章推荐
- PAT (Basic Level) Practise 1001. 害死人不偿命的(3n+1)猜想
- PAT (Basic Level) Practise 1001
- PAT (Basic Level) Practise 1001-1010全部题解
- PAT (Basic Level) Practise (中文)- 1001. 害死人不偿命的(3n+1)猜想 (15)
- PAT(Basic Level)Practise-----1001
- PAT (Basic Level) Practise (中文)1001. 害死人不偿命的(3n+1)猜想 (15)
- PAT (Basic Level) Practise:1001. 害死人不偿命的(3n+1)猜想
- PAT (Basic Level) Practise (中文)1001. 害死人不偿命的(3n+1)猜想 (15) C语言
- PAT (Basic Level) Practise-1001
- PAT Basic level practise 1001
- PAT (Basic Level) Practise (中文)1001害死人不偿命的(3n+1)猜想(15)
- PAT (Basic Level) Practise (中文)1001 【C】
- PAT乙级真题及训练集 PAT (Basic Level) Practise (中文)1001. 害死人不偿命的(3n+1)猜想
- PAT (Basic Level) Practise (中文)--1001
- PAT (Basic Level) Practise (中文)1001. 害死人不偿命的(3n+1)猜想 (15)
- PAT (Basic Level) Practise (中文)1001. 害死人不偿命的(3n+1)猜想
- PAT (Basic Level) Practise (中文)-1027. 打印沙漏(20)
- PAT (Basic Level) Practise (中文)- 1009. 说反话 (20)
- 做完了PAT (Basic Level) Practise (中文)总结一下
- PAT (Basic Level) Practise (中文)1022. D进制的A+B (20)