牛客寒假算法基础集训营2 C 处女座的砝码

题面:https://ac.nowcoder.com/acm/contest/327/C

完全没看懂的题解,但是感觉很厉害就贴在这吧

题解:

以下是代码

#include<bits/stdc++.h>
using namespace std;
const int M = 1e5;
typedef long double ll;
int main()
{
    ll n; cin >> n;
    ll x = 1, s = 1;
    while (x < n)
    {
        x = 3 * x + 1;
        s++;
    }
    cout << s;
    return 0;
}

由于n很大,故用高精度long double来存储,意外的是没有t

猜你喜欢

转载自www.cnblogs.com/harutomimori/p/10316848.html
今日推荐