제출 #15383

#제출 시각아이디문제언어결과실행 시간메모리
15383tonyjjw괄호 문자열 (kriii3_R)C++14
35 / 113
89 ms16708 KiB
#include<stdio.h> #define ML 1000000 #pragma warning(disable:4996) typedef long long ll; int p,q,mod,Q; ll pow2[ML+1]; ll A[ML+1]; int main(){ // freopen("input.txt","r",stdin),freopen("output.txt","w",stdout); scanf("%d%d%d%d",&p,&q,&mod,&Q); int L; for(L=1,pow2[0]=1%mod;L<=ML;L++){ pow2[L]=pow2[L-1]*2%mod; } for(A[1]=0,A[2]=2%mod,L=1;L<=ML-2;L++){ int m=L/2+1; A[L+2]=4*A[L]+(pow2[m]-A[m])*pow2[L+2-2*m]; A[L+2]%=mod; if(A[L+2]<0)A[L+2]+=mod; } for(int i=0;i<Q;i++){ scanf("%d",&L); ll v=pow2[L]-A[L]; v%=mod; if(v<0)v+=mod; printf("%lld\n",v); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...