QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#600230 | #7562. Except One | ucup-team073# | AC ✓ | 1ms | 3832kb | C++20 | 2.6kb | 2024-09-29 15:25:46 | 2024-09-29 15:25:46 |
Judging History
answer
#include<bits/stdc++.h>
#ifdef LOCAL
#define debug(...) printf(__VA_ARGS__)
#define edebug(...) fprintf(stderr, __VA_ARGS__)
#else
#define debug(...)
#define edebug(...)
#endif
#define int ll
#define rep(i, x, y) for(int i = x; i < y; ++i)
#define nrep(i, x, y) for(int i = x; i >= y; --i)
#define lowbit(i) ((i) & -(i))
#define ll long long
#define pii std::pair<int,int>
#define pb emplace_back
#define fi first
#define se second
template <class T>
inline void ckmax(T &a, T b) {
if(a < b) a = b;
}
template <class T>
inline void ckmin(T &a, T b) {
if(a > b) a = b;
}
auto rt_YES = []{puts("YES");};
auto rt_Yes = []{puts("Yes");};
auto rt_NO = []{puts("NO");};
auto rt_No = []{puts("No");};
namespace IO {
#define isdigit(x) (x >= '0' && x <= '9')
inline char gc() {
return getchar();
}
inline bool blank(char ch) {
return ch == ' ' || ch == '\n' || ch == '\r' || ch == '\t';
}
template <class T>
inline void read(T &x) {
double tmp = 1;
bool sign = 0;
x = 0;
char ch = gc();
for(; !isdigit(ch); ch = gc())
if(ch == '-') sign = 1;
for(; isdigit(ch); ch = gc())
x = x * 10 + (ch - '0');
if(ch == '.')
for(ch = gc(); isdigit(ch); ch = gc())
tmp /= 10.0, x += tmp * (ch - '0');
if(sign) x = -x;
}
inline void read(char *s) {
char ch = gc();
for(; blank(ch); ch = gc());
for(; !blank(ch); ch = gc())
*s++ = ch;
*s = 0;
}
inline void read(char &c) {
for(c = gc(); blank(c); c = gc());
}
inline void push(const char &c) {
putchar(c);
}
template <class T>
inline void print(T x) {
if(x < 0) {
x = -x;
push('-');
}
static T sta[35];
T top = 0;
do {
sta[top++] = x % 10;
x /= 10;
} while(x);
while(top)
push(sta[--top] + '0');
}
template <class T>
inline void print(T x, char lastChar) {
print(x);
push(lastChar);
}
}
using namespace IO;
int qpow(int a,int b,int c){
int ans=1;
while(b){
if(b&1)ans=ans*a%c;
a=a*a%c;
b>>=1;
}
return ans;
}
signed main() {
clock_t c1 = clock();
#ifdef LOCAL
freopen("in.in", "r", stdin);
freopen("out.out", "w", stdout);
#endif
//------------------------------------------------------------------
int p,k,t;read(p),read(k),read(t);
int ans=qpow(k,t,p);
if(t%2)ans=p-ans;
print(ans);
//------------------------------------------------------------------
end:
std::cerr << "Time : " << clock() - c1 << " ms" << std::endl;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3692kb
input:
7 5 3
output:
1
result:
ok 1 number(s): "1"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3568kb
input:
11 6 7
output:
3
result:
ok 1 number(s): "3"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3696kb
input:
3 2 1
output:
1
result:
ok 1 number(s): "1"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3828kb
input:
596620183 516846890 38276329
output:
135352707
result:
ok 1 number(s): "135352707"
Test #5:
score: 0
Accepted
time: 0ms
memory: 3744kb
input:
382744931 85302262 235496559
output:
14577469
result:
ok 1 number(s): "14577469"
Test #6:
score: 0
Accepted
time: 0ms
memory: 3688kb
input:
659446013 641119314 378275666
output:
290624162
result:
ok 1 number(s): "290624162"
Test #7:
score: 0
Accepted
time: 0ms
memory: 3688kb
input:
227 163 124
output:
189
result:
ok 1 number(s): "189"
Test #8:
score: 0
Accepted
time: 0ms
memory: 3612kb
input:
197 187 19
output:
62
result:
ok 1 number(s): "62"
Test #9:
score: 0
Accepted
time: 0ms
memory: 3576kb
input:
5 3 3
output:
3
result:
ok 1 number(s): "3"
Test #10:
score: 0
Accepted
time: 0ms
memory: 3832kb
input:
7 6 4
output:
1
result:
ok 1 number(s): "1"
Test #11:
score: 0
Accepted
time: 0ms
memory: 3612kb
input:
7 1 1
output:
6
result:
ok 1 number(s): "6"
Test #12:
score: 0
Accepted
time: 1ms
memory: 3572kb
input:
782371 586755 418517
output:
298550
result:
ok 1 number(s): "298550"
Test #13:
score: 0
Accepted
time: 0ms
memory: 3612kb
input:
181081 178315 76002
output:
125177
result:
ok 1 number(s): "125177"
Test #14:
score: 0
Accepted
time: 0ms
memory: 3704kb
input:
715019 492103 446729
output:
221541
result:
ok 1 number(s): "221541"
Test #15:
score: 0
Accepted
time: 0ms
memory: 3688kb
input:
238985261 199832612 162675695
output:
65826267
result:
ok 1 number(s): "65826267"
Test #16:
score: 0
Accepted
time: 0ms
memory: 3772kb
input:
129716453 10994076 62963738
output:
5186275
result:
ok 1 number(s): "5186275"
Test #17:
score: 0
Accepted
time: 0ms
memory: 3696kb
input:
962360593 652577122 345596237
output:
814039152
result:
ok 1 number(s): "814039152"
Test #18:
score: 0
Accepted
time: 0ms
memory: 3748kb
input:
871606937 839183139 754188014
output:
466391387
result:
ok 1 number(s): "466391387"
Test #19:
score: 0
Accepted
time: 0ms
memory: 3776kb
input:
275568091 270750503 241146839
output:
252569968
result:
ok 1 number(s): "252569968"
Test #20:
score: 0
Accepted
time: 0ms
memory: 3568kb
input:
562028473 111749710 450258818
output:
63116256
result:
ok 1 number(s): "63116256"