daolao 求调,#9 TLE 92 pts
查看原帖
daolao 求调,#9 TLE 92 pts
840824
superLouis楼主2025/1/24 21:28
#include <bits/stdc++.h>
using namespace std;
#define int long long
int l, r, w;
inline int qpow(int a, int b) { int ans = 1; while (b > 0) { if (b & 1) ans *= a; a *= a; b >>= 1; } return ans; }
inline int log_floor(int x, int y) { if (y < x) return 0; int res = 0; while (y / x) y /= x, res++; return res; }
inline int log_ceil(int x, int y) { int tmp = log_floor(x, y); return tmp + !(qpow(x, tmp) == y); }
inline int rint() {
    register int k = 0, f = 0; register char c = getchar();
    while (!isdigit(c)) { if (c == '-') f ^= -1; c = getchar(); }
    while (isdigit(c)) { k = (k << 1) + (k << 3) + (c ^ '0'); c = getchar(); }
    return f ? -k : k;
}
signed main(signed argc, char* argv[]) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    l = rint(), r = rint(), w = rint();
    int x = log_ceil(w, l), y = log_floor(w, r);
    if (x > y) return cout << "-1\n", 0;
    for (int i = x; i <= y; i++) cout << qpow(w, i) << " \n"[i == y];
    return 0;
}
2025/1/24 21:28
加载中...