This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |