'commit'
This commit is contained in:
18
C++课程/习题训练/3N+1问题_2.cpp
Normal file
18
C++课程/习题训练/3N+1问题_2.cpp
Normal file
@@ -0,0 +1,18 @@
|
||||
#include<bits/stdc++.h>
|
||||
using namespace std;
|
||||
int main()
|
||||
{
|
||||
int count = 0;
|
||||
long long n;//<2F><><EFBFBD><EFBFBD>64λ<34><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
scanf("%lld", &n);//<2F>˴<EFBFBD>"%lld"Ҳ<><D2B2>д<EFBFBD><D0B4>"%I64d"
|
||||
while(n > 1)
|
||||
{
|
||||
if(n%2 == 1) n = n * 3 + 1;
|
||||
else n /= 2;
|
||||
count++;
|
||||
}
|
||||
printf("%d\n", count);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user