平衡三进制

平衡三进制—百度百科

一道简单平衡三进制题目:

牛客—处女座的砝码

参考:https://blog.csdn.net/Sherry_Yue/article/details/86658533

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//submit time:2019-01-28 22:26:07

#include<iostream>

using namespace std;

int main()
{
long double n, res = 0, cnt = 0;
cin >> n;
while(cnt < n)
{
cnt = 3 * cnt + 1;
res++;
}
cout << res << endl;
return 0;
}

long long与 long double

按道理来说,long doubledoublelong long要表示的范围要大,但是依据情况而定,在本机64位机测试上测试:

1
2
3
sizeof(long double) = 16
sizeof(long long) = 8
sizeof(double) = 8

更多了解:

poj1702—Eva’s Balance

https://blog.csdn.net/yeruby/article/details/47047385