Created
October 24, 2012 06:28
-
-
Save diego9627/3944381 to your computer and use it in GitHub Desktop.
Engranes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<cstdio> | |
int colores[1000000]; | |
bool iguales[1000000]; | |
long long mcd(long long N,long long M){ | |
if(N==0) return M; | |
else return mcd(M%N,N); | |
} | |
int main(){ | |
long long N,M,k,T,i,d,in; | |
int c; | |
scanf("%lld %lld %lld",&N,&M,&k); | |
d=mcd(N,M); | |
for(i=0;i<d;i++){ | |
scanf("%d",&colores[i]); | |
iguales[i]=true; | |
} | |
for(i=d;i<N;i++){ | |
scanf("%d",&c); | |
if(c!=colores[i%d]) iguales[i%d]=false; | |
} | |
scanf("%lld",&T); | |
for(i=0;i<T;i++){ | |
scanf("%lld",&in); | |
if(iguales[in%d]) printf("1"); | |
else printf("0"); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment