QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#786867#5715. 幂次lopzith35 4ms19596kbC++142.7kb2024-11-27 00:19:002024-11-27 00:19:07

Judging History

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

  • [2024-11-27 00:19:07]
  • 评测
  • 测评结果:35
  • 用时:4ms
  • 内存:19596kb
  • [2024-11-27 00:19:00]
  • 提交

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)
            {
                int 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
}

详细


Pretests


Final Tests

Test #1:

score: 5
Accepted
time: 2ms
memory: 19432kb

input:

92 1

output:

92

result:

ok 1 number(s): "92"

Test #2:

score: 0
Wrong Answer
time: 2ms
memory: 19384kb

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: 19312kb

input:

9383 3

output:

37

result:

ok 1 number(s): "37"

Test #4:

score: 0
Wrong Answer
time: 3ms
memory: 19276kb

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: 19544kb

input:

927700 3

output:

149

result:

ok 1 number(s): "149"

Test #6:

score: 0
Wrong Answer
time: 3ms
memory: 19392kb

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: 19060kb

input:

94345650 3

output:

605

result:

ok 1 number(s): "605"

Test #8:

score: 0
Wrong Answer
time: 3ms
memory: 19260kb

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: 19596kb

input:

9328450690 3

output:

2541

result:

ok 1 number(s): "2541"

Test #10:

score: 0
Wrong Answer
time: 3ms
memory: 19300kb

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: 19060kb

input:

948459050000 3

output:

11116

result:

ok 1 number(s): "11116"

Test #12:

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

input:

993120563000 2

output:


result:

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

Test #13:

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

input:

93781484300000 3

output:

49275

result:

ok 1 number(s): "49275"

Test #14:

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

input:

98250912400000 2

output:


result:

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

Test #15:

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

input:

9272034040000000 3

output:

339972

result:

wrong answer 1st numbers differ - expected: '221661', found: '339972'

Test #16:

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

input:

9981231040000000 2

output:


result:

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

Test #17:

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

input:

942817384000000000 3

output:

2970913

result:

wrong answer 1st numbers differ - expected: '1016053', found: '2970913'

Test #18:

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

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: 19368kb

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: 4ms
memory: 19116kb

input:

992520149596833024 2

output:


result:

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