QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#786872#5715. 幂次lopzith45 4ms19640kbC++142.7kb2024-11-27 00:21:532024-11-27 00:21:53

Judging History

你现在查看的是最新测评结果

  • [2024-11-27 00:21:53]
  • 评测
  • 测评结果:45
  • 用时:4ms
  • 内存:19640kb
  • [2024-11-27 00:21:53]
  • 提交

answer

#include <bits/stdc++.h>
#include <bits/extc++.h>
using namespace __gnu_pbds;
#define DEFAULT 5e5 + 5
#define int long long
#define i64 long long
#define i128 __int128
#define ull unsigned long long
#define db double
#define ldb long double
#define Arr std::vector
#define Ptn std::pair
#define fi first
#define se second
#define eb emplace_back
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define popc(x) __builtin_popcountll(x)
#define clz(x) __builtin_clzll(x)
#define ctz(x) __builtin_ctzll(x)
#define chkmin(x, y) x = std::min(x, y)
#define chkmax(x, y) x = std::max(x, y)
#define FILE(x) freopen(x ".in", "r", stdin), freopen(x ".out", "w", stdout)
#define TEST(x) freopen(x ".in", "r", stdin), freopen("test.out", "w", stdout)
#define KEL(x) freopen(x ".in", "r", stdin), freopen("a.out", "w", stdout)
#define debug std::cout << "Running on " << __FUNCTION__ << ' ' << __LINE__ << std::endl;
#define fail assert(0);
#define lopzith return 0;
bool BeginPoint;
const int INF = 0x3f3f3f3f, llINF = 0x3f3f3f3f3f3f3f3f, P = 998244353;
const db eps = 1e-9;
const ull base = 13331;
const int N = 1e6 + 5;
int n, k, m, ans, A[N], vis[N];

inline int read()
{
    int w = 0, f = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9')
    {
        if (ch == '-') f = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9')
    {
        w = (w << 3) + (w << 1) + (ch - 48);
        ch = getchar();
    }
    return w * f;
}

void init()
{
    for (int i = 2; i < N; i++)
    {
        if (vis[i]) continue;
        A[++m] = i;
        for (int p = i * i; p < N; p *= i) vis[p] = 1;
    }
}

bool EndPoint;
signed main()
{
    std::cerr << "Memory = " << fabs(&BeginPoint - &EndPoint) / 1048576.0 << "MB" << std::endl;

    n = read(), k = read();
    init();
    if (k == 1) return printf("%lld\n", n), 0;
    if (k >= 3)
    {
        for (int i = 100; i >= k; i--)
        {
            auto chk = [&](int x)
            {
                i128 mul = 1;
                for (int j = 1; j <= i; j++)
                {
                    mul *= A[x];
                    if (mul > n) return false;
                } 
                return true;
            };
            int L = 1, R = m, aans = 0;
            while (L <= R)
            {
                int mid = (L + R) >> 1;
                if (chk(mid)) L = mid + 1, aans = mid;
                else R = mid - 1;
            }
            ans += aans;
        }
        printf("%lld\n", ans + 1);
    }
    else 
    {

    }

    std::cerr << "Time = " << (double)clock() / CLOCKS_PER_SEC << "s" << std::endl;
    lopzith
}

Details

Tip: Click on the bar to expand more detailed information

Pretests


Final Tests

Test #1:

score: 5
Accepted
time: 0ms
memory: 19084kb

input:

92 1

output:

92

result:

ok 1 number(s): "92"

Test #2:

score: 0
Wrong Answer
time: 0ms
memory: 19512kb

input:

96 2

output:


result:

wrong answer Answer contains longer sequence [length = 1], but output contains 0 elements

Test #3:

score: 5
Accepted
time: 0ms
memory: 19508kb

input:

9383 3

output:

37

result:

ok 1 number(s): "37"

Test #4:

score: 0
Wrong Answer
time: 0ms
memory: 19268kb

input:

9830 2

output:


result:

wrong answer Answer contains longer sequence [length = 1], but output contains 0 elements

Test #5:

score: 5
Accepted
time: 0ms
memory: 19540kb

input:

927700 3

output:

149

result:

ok 1 number(s): "149"

Test #6:

score: 0
Wrong Answer
time: 0ms
memory: 19552kb

input:

972504 2

output:


result:

wrong answer Answer contains longer sequence [length = 1], but output contains 0 elements

Test #7:

score: 5
Accepted
time: 0ms
memory: 19112kb

input:

94345650 3

output:

605

result:

ok 1 number(s): "605"

Test #8:

score: 0
Wrong Answer
time: 0ms
memory: 19568kb

input:

98811802 2

output:


result:

wrong answer Answer contains longer sequence [length = 1], but output contains 0 elements

Test #9:

score: 5
Accepted
time: 0ms
memory: 19196kb

input:

9328450690 3

output:

2541

result:

ok 1 number(s): "2541"

Test #10:

score: 0
Wrong Answer
time: 0ms
memory: 19544kb

input:

9775065820 2

output:


result:

wrong answer Answer contains longer sequence [length = 1], but output contains 0 elements

Test #11:

score: 5
Accepted
time: 0ms
memory: 19524kb

input:

948459050000 3

output:

11116

result:

ok 1 number(s): "11116"

Test #12:

score: 0
Wrong Answer
time: 4ms
memory: 19352kb

input:

993120563000 2

output:


result:

wrong answer Answer contains longer sequence [length = 1], but output contains 0 elements

Test #13:

score: 5
Accepted
time: 0ms
memory: 19640kb

input:

93781484300000 3

output:

49275

result:

ok 1 number(s): "49275"

Test #14:

score: 0
Wrong Answer
time: 0ms
memory: 19552kb

input:

98250912400000 2

output:


result:

wrong answer Answer contains longer sequence [length = 1], but output contains 0 elements

Test #15:

score: 5
Accepted
time: 0ms
memory: 19528kb

input:

9272034040000000 3

output:

221661

result:

ok 1 number(s): "221661"

Test #16:

score: 0
Wrong Answer
time: 0ms
memory: 19556kb

input:

9981231040000000 2

output:


result:

wrong answer Answer contains longer sequence [length = 1], but output contains 0 elements

Test #17:

score: 5
Accepted
time: 3ms
memory: 19444kb

input:

942817384000000000 3

output:

1016053

result:

ok 1 number(s): "1016053"

Test #18:

score: 0
Wrong Answer
time: 0ms
memory: 19076kb

input:

987478897000000000 2

output:


result:

wrong answer Answer contains longer sequence [length = 1], but output contains 0 elements

Test #19:

score: 0
Wrong Answer
time: 0ms
memory: 19396kb

input:

932205945000000000 2

output:


result:

wrong answer Answer contains longer sequence [length = 1], but output contains 0 elements

Test #20:

score: 0
Wrong Answer
time: 0ms
memory: 19344kb

input:

992520149596833024 2

output:


result:

wrong answer Answer contains longer sequence [length = 1], but output contains 0 elements