QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#49607 | #2601. Lucky Tickets | Crysfly | AC ✓ | 306ms | 7300kb | C++11 | 2.8kb | 2022-09-22 08:50:50 | 2022-09-22 08:50:52 |
Judging History
answer
#include<bits/stdc++.h>
#define For(i,a,b) for(register int i=(a);i<=(b);++i)
#define Rep(i,a,b) for(register int i=(a);i>=(b);--i)
using namespace std;
inline int read()
{
char c=getchar();int x=0;bool f=0;
for(;!isdigit(c);c=getchar())f^=!(c^45);
for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+(c^48);
if(f)x=-x;return x;
}
int mod;
struct modint{
int x;
modint(int o=0){x=o;}
modint &operator = (int o){return x=o,*this;}
modint &operator +=(modint o){return x=x+o.x>=mod?x+o.x-mod:x+o.x,*this;}
modint &operator -=(modint o){return x=x-o.x<0?x-o.x+mod:x-o.x,*this;}
modint &operator *=(modint o){return x=1ll*x*o.x%mod,*this;}
modint &operator ^=(int b){
modint a=*this,c=1;
for(;b;b>>=1,a*=a)if(b&1)c*=a;
return x=c.x,*this;
}
modint &operator /=(modint o){return *this *=o^=mod-2;}
modint &operator +=(int o){return x=x+o>=mod?x+o-mod:x+o,*this;}
modint &operator -=(int o){return x=x-o<0?x-o+mod:x-o,*this;}
modint &operator *=(int o){return x=1ll*x*o%mod,*this;}
modint &operator /=(int o){return *this *= ((modint(o))^=mod-2);}
template<class I>friend modint operator +(modint a,I b){return a+=b;}
template<class I>friend modint operator -(modint a,I b){return a-=b;}
template<class I>friend modint operator *(modint a,I b){return a*=b;}
template<class I>friend modint operator /(modint a,I b){return a/=b;}
friend modint operator ^(modint a,int b){return a^=b;}
friend bool operator ==(modint a,int b){return a.x==b;}
friend bool operator !=(modint a,int b){return a.x!=b;}
bool operator ! () {return !x;}
modint operator - () {return x?mod-x:0;}
bool operator <(const modint&b)const{return x<b.x;}
};
vector<modint> fac,ifac,iv;
inline void initC(int n)
{
if(iv.empty())fac=ifac=iv=vector<modint>(2,1);
int m=iv.size(); ++n;
if(m>=n)return;
iv.resize(n),fac.resize(n),ifac.resize(n);
For(i,m,n-1){
iv[i]=iv[mod%i]*(mod-mod/i);
fac[i]=fac[i-1]*i,ifac[i]=ifac[i-1]*iv[i];
}
}
inline modint C(int n,int m){
if(m<0||n<m)return 0;
return initC(n),fac[n]*ifac[m]*ifac[n-m];
}
inline modint sign(int n){return (n&1)?(mod-1):(1);}
inline modint qpow(modint x,int y){return x^y;}
#define fi first
#define se second
#define pb push_back
#define mkp make_pair
typedef pair<int,int>pii;
typedef vector<int>vi;
#define maxn 1000005
#define inf 0x3f3f3f3f
int n,q,s;
int cnt[1231231];
int vec[1231231],len;
signed main()
{
n=read(),s=read(),q=read();
mod=n;
For(i,0,n-1){
modint now=i;
now^=q;
now+=1ll*i*q%n;
if(now.x==s) vec[++len]=i;
// cnt[now.x]++;
// cout<<now.x<<" ";
}//puts("");
// 000 111=1 222=2
// 222 : (2+1)*(2+2)*(2+3)
mod=q;
modint res=0;
modint mul=(qpow(2,q)-1);
// cout<<"mul: "<<mul.x<<endl;
For(i,1,len){
int x=vec[i];
res+=mul*x;
}
// 2 2 2
// 2 * 7
cout<<res.x;
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3540kb
input:
2 0 2
output:
0
result:
ok 1 number(s): "0"
Test #2:
score: 0
Accepted
time: 2ms
memory: 3552kb
input:
10 9 2
output:
1
result:
ok 1 number(s): "1"
Test #3:
score: 0
Accepted
time: 2ms
memory: 3552kb
input:
3 2 3
output:
2
result:
ok 1 number(s): "2"
Test #4:
score: 0
Accepted
time: 2ms
memory: 3500kb
input:
2 1 2
output:
1
result:
ok 1 number(s): "1"
Test #5:
score: 0
Accepted
time: 2ms
memory: 3552kb
input:
4 0 3
output:
1
result:
ok 1 number(s): "1"
Test #6:
score: 0
Accepted
time: 2ms
memory: 3516kb
input:
4 2 3
output:
2
result:
ok 1 number(s): "2"
Test #7:
score: 0
Accepted
time: 2ms
memory: 3516kb
input:
20 4 19
output:
5
result:
ok 1 number(s): "5"
Test #8:
score: 0
Accepted
time: 2ms
memory: 3540kb
input:
30 2 37
output:
23
result:
ok 1 number(s): "23"
Test #9:
score: 0
Accepted
time: 2ms
memory: 3424kb
input:
87 22 67
output:
0
result:
ok 1 number(s): "0"
Test #10:
score: 0
Accepted
time: 2ms
memory: 3620kb
input:
829 135 857
output:
803
result:
ok 1 number(s): "803"
Test #11:
score: 0
Accepted
time: 3ms
memory: 3500kb
input:
6120 2790 9851
output:
4622
result:
ok 1 number(s): "4622"
Test #12:
score: 0
Accepted
time: 17ms
memory: 3624kb
input:
77263 13087 50147
output:
26904
result:
ok 1 number(s): "26904"
Test #13:
score: 0
Accepted
time: 204ms
memory: 3484kb
input:
682298 437284 638801
output:
10038
result:
ok 1 number(s): "10038"
Test #14:
score: 0
Accepted
time: 239ms
memory: 3548kb
input:
823965 703789 575623
output:
483248
result:
ok 1 number(s): "483248"
Test #15:
score: 0
Accepted
time: 295ms
memory: 3552kb
input:
1000000 394496 999983
output:
755554
result:
ok 1 number(s): "755554"
Test #16:
score: 0
Accepted
time: 290ms
memory: 3648kb
input:
1000000 24900 999451
output:
996185
result:
ok 1 number(s): "996185"
Test #17:
score: 0
Accepted
time: 301ms
memory: 3508kb
input:
999750 14190 999671
output:
191073
result:
ok 1 number(s): "191073"
Test #18:
score: 0
Accepted
time: 282ms
memory: 3684kb
input:
946312 10286 997741
output:
744939
result:
ok 1 number(s): "744939"
Test #19:
score: 0
Accepted
time: 306ms
memory: 4160kb
input:
997742 0 997741
output:
565729
result:
ok 1 number(s): "565729"
Test #20:
score: 0
Accepted
time: 300ms
memory: 7300kb
input:
977762 0 977761
output:
0
result:
ok 1 number(s): "0"