QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#261206 | #7838. 往日之影 | 275307894a | 0 | 3ms | 4060kb | C++14 | 1.9kb | 2023-11-22 19:01:54 | 2023-11-22 19:01:55 |
answer
#include<bits/stdc++.h>
#define Gc() getchar()
#define Me(x,y) memset(x,y,sizeof(x))
#define Mc(x,y) memcpy(x,y,sizeof(x))
#define d(x,y) ((m)*(x-1)+(y))
#define R(n) (rnd()%(n)+1)
#define Pc(x) putchar(x)
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define eb emplace_back
using namespace std;using ll=long long;using db=double;using lb=long db;using ui=unsigned;using ull=unsigned long long;using pii=pair<int,int>;using LL=__int128;
const int N=1e6+5,M=N*4+5,K=(1<<25)+5,mod=1e9+7,Mod=mod-1;const db eps=1e-9;const int INF=1e9+7;mt19937 rnd(time(0));
int p,n,a[4];
struct img{
ll a,b;
img operator +(const img &B)const{return (img){(a+B.a)%p,(b+B.b)%p};}
img operator -(const img &B)const{return (img){(a-B.a)%p,(b-B.b)%p};}
img operator *(const img &B)const{return (img){(a*B.a-b*B.b)%p,(a*B.b+b*B.a)%p};}
};
img mpow(img x,ll y){img ans=(img){1,0};while(y) y&1&&(ans=ans*x,0),y>>=1,x=x*x;return ans;}
ll mpow(ll x,ll y=p-2){ll ans=1;while(y) y&1&&(ans=ans*x%p),y>>=1,x=x*x%p;return ans;}
int c[4];
ll ans;
void calc(int x,img y){
for(int i=0;i<4;i++){
y=y*mpow((img){0,1},a[i]*(4-i)*x);
c[x]+=a[i];
}
for(int i=0;i<4;i++){
y=y*mpow(mpow((img){0,1},2*i)+(img){1,0},1ll*c[i]*(c[i]-1)/2);
for(int j=i+1;j<4;j++) y=y*mpow(mpow((img){0,1},i+j)+(img){1,0},1ll*c[i]*c[j]);
}
for(int i=0;i<4;i++) c[x]-=a[i];
ans+=y.a;
}
void dfs(int x,img w){
if(x==5) return calc(0,w),calc(2,w);
dfs(x+2,w);
for(int i=0;i<4;i++) if(a[i]) a[i]--,c[x]++,dfs(x+2,w*(img){a[i]+1,0}*mpow((img){0,1},(4-i)*x)),c[x]--,a[i]++;
}
void Solve(){
int i,j;scanf("%d",&n);
for(i=0;i<4;i++) scanf("%d",&a[i]);
ans=0;dfs(1,(img){1,0});
printf("%lld\n",(ans%p+p)*mpow(mpow(4,n)*mpow(2,1ll*n*(n-1)/2)%p)%p);
}
int main(){
int t=1;
scanf("%d%d",&t,&p);
while(t--) Solve();
cerr<<clock()*1.0/CLOCKS_PER_SEC<<'\n';
}
详细
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 10
Accepted
time: 1ms
memory: 3928kb
input:
1 998244353 3 1 1 0 1
output:
0
result:
ok single line: '0'
Test #2:
score: 0
Accepted
time: 1ms
memory: 4020kb
input:
1 998244353 7 0 2 1 4
output:
998069185
result:
ok single line: '998069185'
Test #3:
score: 0
Accepted
time: 0ms
memory: 4060kb
input:
1 998244353 4 0 1 0 3
output:
0
result:
ok single line: '0'
Test #4:
score: -10
Wrong Answer
time: 0ms
memory: 3900kb
input:
1 998244353 2 1 0 1 0
output:
124780544
result:
wrong answer 1st lines differ - expected: '0', found: '124780544'
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Skipped
Dependency #2:
0%
Subtask #4:
score: 0
Wrong Answer
Test #23:
score: 0
Wrong Answer
time: 3ms
memory: 3976kb
input:
999 999999001 2 2 0 0 0 3 3 0 0 0 4 4 0 0 0 5 5 0 0 0 6 6 0 0 0 7 7 0 0 0 8 8 0 0 0 9 9 0 0 0 10 10 0 0 0 11 11 0 0 0 12 12 0 0 0 13 13 0 0 0 14 14 0 0 0 15 15 0 0 0 16 16 0 0 0 17 17 0 0 0 18 18 0 0 0 19 19 0 0 0 20 20 0 0 0 21 21 0 0 0 22 22 0 0 0 23 23 0 0 0 24 24 0 0 0 25 25 0 0 0 26 26 0 0 0 27...
output:
374999626 874999126 359374641 919920956 691222454 586081873 33512082 496961574 790501684 206445579 708073277 492142887 486007979 21786019 802052117 198521403 854660059 658779344 904643630 538486221 357736277 949763680 94144464 342842045 695164947 276856011 552666277 813428208 572457238 910726512 177...
result:
wrong answer 1st lines differ - expected: '499999501', found: '374999626'
Subtask #5:
score: 0
Skipped
Dependency #1:
0%