90分求助

P3612 [USACO17JAN] Secret Cow Code S

_DtrIsta3int @ 2021-10-22 17:40:24

第二个测试点没过...

#include<iostream>
#include<cstring>
#include<cmath>
using namespace std;
int main()
{
    string a;
    long long n, t = 0;
    cin >> a;
    cin >> n;
    long long len = a.size(), cnt = log10((n - 1) / len) / log10(2);
    while (n > len)
    {
        long long temp = n;
        n = n - pow(2, cnt) * len - 1;
        if (n <= 0)n = temp - 1;
        cnt = log10((n - 1) / len) / log10(2);
    }
    cout << a[n - 1];
}

评测记录


by _DtrIsta3int @ 2021-10-23 18:37:02

原来是Log函数的问题,已AC,此贴终结


by raymonds @ 2022-08-12 15:44:15

同2没过,想问下具体是log函数的什么问题


|