QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#206100#7562. Except Oneucup-team368#AC ✓0ms3740kbC++202.1kb2023-10-07 18:35:592023-10-07 18:35:59

Judging History

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

  • [2023-10-07 18:35:59]
  • 评测
  • 测评结果:AC
  • 用时:0ms
  • 内存:3740kb
  • [2023-10-07 18:35:59]
  • 提交

answer

#ifndef Yamada
#define Yamada
#include Yamada __FILE__ Yamada

int fpow(int base, int mod, int exp, int ans = 1) {
    while (exp) {
        if (exp & 1) ans = ans * base % mod;
        exp >>= 1, base = base * base % mod;
    }
    return ans;
}

void solve() {
    int p, k, t; cin >> p >> k >> t;

    int ans = fpow(k, p, t-1);
    ans = ans * ((p * (p-1) / 2 - k) % p + p) % p;
    int sgn = (t % 2 == 1 ? 1 : -1);
    ans = (sgn * ans + p) % p;
    cout << ans << '\n';
}

signed main() {
    IOS();
    int t = 1; // cin >> t;
    for (int i=1;i<=t;++i) solve();
    return 0;
}

#else

#ifdef cold66
#define _GLIBCXX_DEBUG 1
#endif
#pragma GCC optimize ("Ofast", "unroll-loops")
#include <bits/stdc++.h>
using namespace std;

#define int int64_t
// #define double __float80
using pii = pair<int, int>;
template <typename T> using MaxHeap = priority_queue<T>;
template <typename T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

#define SZ(a) ((int)(a).size())
#define ALL(a) begin(a), end(a)
#define RALL(a) rbegin(a), rend(a)
#define ee emplace
#define eb emplace_back
#define ef emplace_front
#define pb pop_back
#define pf pop_front
// #define X first
// #define Y second

template <size_t D, typename T> struct Vec : vector<Vec<D-1, T>> {
    template <typename... U> Vec(int n = 0, U ... _u) : vector<Vec<D-1, T>>(n, Vec<D-1, T>(_u...)) {}
};
template <typename T> struct Vec<1, T> : vector<T> {
    Vec(int n = 0, const T& val = T()) : vector<T>(n, val) {}
};

#ifdef local
#define IOS() void()
#define debug(...) \
    fprintf(stderr, "\u001b[33m"), \
    fprintf(stderr, "At [%s], line %d: (%s) = ", __FUNCTION__, __LINE__, #__VA_ARGS__), \
    _do(__VA_ARGS__), \
    fprintf(stderr, "\u001b[0m")
template <typename T> void _do(T &&_t) {cerr << _t << endl;}
template <typename T, typename ...U> void _do(T &&_t, U &&..._u) {cerr << _t << ", ", _do(_u...);}
#else
#define IOS() ios_base::sync_with_stdio(0); cin.tie(0)
#define debug(...) void()
#define endl '\n'
#endif

template <typename U, typename V> bool chmin(U &u, V v) {return u > v ? u = v, 1 : 0;}
template <typename U, typename V> bool chmax(U &u, V v) {return u < v ? u = v, 1 : 0;}

#endif

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3604kb

input:

7 5 3

output:

1

result:

ok 1 number(s): "1"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3668kb

input:

11 6 7

output:

3

result:

ok 1 number(s): "3"

Test #3:

score: 0
Accepted
time: 0ms
memory: 3596kb

input:

3 2 1

output:

1

result:

ok 1 number(s): "1"

Test #4:

score: 0
Accepted
time: 0ms
memory: 3604kb

input:

596620183 516846890 38276329

output:

135352707

result:

ok 1 number(s): "135352707"

Test #5:

score: 0
Accepted
time: 0ms
memory: 3672kb

input:

382744931 85302262 235496559

output:

14577469

result:

ok 1 number(s): "14577469"

Test #6:

score: 0
Accepted
time: 0ms
memory: 3668kb

input:

659446013 641119314 378275666

output:

290624162

result:

ok 1 number(s): "290624162"

Test #7:

score: 0
Accepted
time: 0ms
memory: 3656kb

input:

227 163 124

output:

189

result:

ok 1 number(s): "189"

Test #8:

score: 0
Accepted
time: 0ms
memory: 3684kb

input:

197 187 19

output:

62

result:

ok 1 number(s): "62"

Test #9:

score: 0
Accepted
time: 0ms
memory: 3668kb

input:

5 3 3

output:

3

result:

ok 1 number(s): "3"

Test #10:

score: 0
Accepted
time: 0ms
memory: 3680kb

input:

7 6 4

output:

1

result:

ok 1 number(s): "1"

Test #11:

score: 0
Accepted
time: 0ms
memory: 3740kb

input:

7 1 1

output:

6

result:

ok 1 number(s): "6"

Test #12:

score: 0
Accepted
time: 0ms
memory: 3668kb

input:

782371 586755 418517

output:

298550

result:

ok 1 number(s): "298550"

Test #13:

score: 0
Accepted
time: 0ms
memory: 3604kb

input:

181081 178315 76002

output:

125177

result:

ok 1 number(s): "125177"

Test #14:

score: 0
Accepted
time: 0ms
memory: 3736kb

input:

715019 492103 446729

output:

221541

result:

ok 1 number(s): "221541"

Test #15:

score: 0
Accepted
time: 0ms
memory: 3668kb

input:

238985261 199832612 162675695

output:

65826267

result:

ok 1 number(s): "65826267"

Test #16:

score: 0
Accepted
time: 0ms
memory: 3672kb

input:

129716453 10994076 62963738

output:

5186275

result:

ok 1 number(s): "5186275"

Test #17:

score: 0
Accepted
time: 0ms
memory: 3596kb

input:

962360593 652577122 345596237

output:

814039152

result:

ok 1 number(s): "814039152"

Test #18:

score: 0
Accepted
time: 0ms
memory: 3664kb

input:

871606937 839183139 754188014

output:

466391387

result:

ok 1 number(s): "466391387"

Test #19:

score: 0
Accepted
time: 0ms
memory: 3728kb

input:

275568091 270750503 241146839

output:

252569968

result:

ok 1 number(s): "252569968"

Test #20:

score: 0
Accepted
time: 0ms
memory: 3608kb

input:

562028473 111749710 450258818

output:

63116256

result:

ok 1 number(s): "63116256"