QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#886604#2601. Lucky TicketsLuluAC ✓136ms3584kbC++141.1kb2025-02-07 10:01:292025-02-07 10:01:30

Judging History

This is the latest submission verdict.

  • [2025-02-07 10:01:30]
  • Judged
  • Verdict: AC
  • Time: 136ms
  • Memory: 3584kb
  • [2025-02-07 10:01:29]
  • Submitted

answer

/*
Author:Eraine
Contest:HB #6
Problem:lucky
Time:2025.2.6
Calm down!
Think carefully and type.
*/
#include<bits/stdc++.h>
#define ll long long
#define pi pair<int,int>
#define mkp(x,y) make_pair(x,y)
#define fi first
#define se second
#define lc tr[i].ch[0]
#define rc tr[i].ch[1]
#define Lc tr[j].ch[0]
#define Rc tr[j].ch[1]
#define REP(i,l,r) for(int i=(l);i<=(r);i++)
#define PER(i,r,l) for(int i=(r);i>=(l);i--)
using namespace std;
inline int read(){
    int x=0,f=1;
    char c=getchar();
    while(!isdigit(c)){
        if(c=='-')f=-1;
        c=getchar();
    }
    while(isdigit(c)){
        x=(x<<3)+(x<<1)+c-'0';
        c=getchar();
    }
    return x*f;
}
void write(int x){
    if(x<0)putchar('-'),x=-x;
    if(x>9)write(x/10);
    putchar(x%10+'0');
}
const int N=2e6+5;
ll qpow(ll b,ll p,ll mod){
    ll res=1,x=b;
    for(ll w=1;w<=p;w<<=1){
        if(w&p)res=res*x%mod;
        x=x*x%mod;
    }
    return res;
}
int main(){
    int n=read(),s=read(),q=read(),res=0;
    REP(i,0,n-1)if((qpow(i,q,n)+1ll*i*q)%n==s)res+=i,res%=q;
    write(res),putchar('\n');
    return 0;
}

詳細信息

Test #1:

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

input:

2 0 2

output:

0

result:

ok 1 number(s): "0"

Test #2:

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

input:

10 9 2

output:

1

result:

ok 1 number(s): "1"

Test #3:

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

input:

3 2 3

output:

2

result:

ok 1 number(s): "2"

Test #4:

score: 0
Accepted
time: 1ms
memory: 3456kb

input:

2 1 2

output:

1

result:

ok 1 number(s): "1"

Test #5:

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

input:

4 0 3

output:

1

result:

ok 1 number(s): "1"

Test #6:

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

input:

4 2 3

output:

2

result:

ok 1 number(s): "2"

Test #7:

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

input:

20 4 19

output:

5

result:

ok 1 number(s): "5"

Test #8:

score: 0
Accepted
time: 1ms
memory: 3584kb

input:

30 2 37

output:

23

result:

ok 1 number(s): "23"

Test #9:

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

input:

87 22 67

output:

0

result:

ok 1 number(s): "0"

Test #10:

score: 0
Accepted
time: 1ms
memory: 3584kb

input:

829 135 857

output:

803

result:

ok 1 number(s): "803"

Test #11:

score: 0
Accepted
time: 1ms
memory: 3456kb

input:

6120 2790 9851

output:

4622

result:

ok 1 number(s): "4622"

Test #12:

score: 0
Accepted
time: 6ms
memory: 3584kb

input:

77263 13087 50147

output:

26904

result:

ok 1 number(s): "26904"

Test #13:

score: 0
Accepted
time: 84ms
memory: 3584kb

input:

682298 437284 638801

output:

10038

result:

ok 1 number(s): "10038"

Test #14:

score: 0
Accepted
time: 89ms
memory: 3584kb

input:

823965 703789 575623

output:

483248

result:

ok 1 number(s): "483248"

Test #15:

score: 0
Accepted
time: 127ms
memory: 3584kb

input:

1000000 394496 999983

output:

755554

result:

ok 1 number(s): "755554"

Test #16:

score: 0
Accepted
time: 123ms
memory: 3584kb

input:

1000000 24900 999451

output:

996185

result:

ok 1 number(s): "996185"

Test #17:

score: 0
Accepted
time: 131ms
memory: 3584kb

input:

999750 14190 999671

output:

191073

result:

ok 1 number(s): "191073"

Test #18:

score: 0
Accepted
time: 123ms
memory: 3584kb

input:

946312 10286 997741

output:

744939

result:

ok 1 number(s): "744939"

Test #19:

score: 0
Accepted
time: 136ms
memory: 3584kb

input:

997742 0 997741

output:

565729

result:

ok 1 number(s): "565729"

Test #20:

score: 0
Accepted
time: 126ms
memory: 3584kb

input:

977762 0 977761

output:

0

result:

ok 1 number(s): "0"