Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main() {
- int i, numsapo, numpedras;
- scanf("%d %d", &numpedras, &numsapo);
- int vetor[numpedras], position, salt, soma, soma1;
- for(i=0; i<numpedras; i++) vetor[i] = 0;
- for(i=1; i<=numsapo; i++) {
- scanf("%d %d", &position, &salt);
- if(position != 0) vetor[position-1] = 1;
- soma = position+salt;
- soma1 = position-salt;
- while(soma <= numpedras) {
- vetor[soma-1] = 1;
- soma = soma + salt; }
- while(soma1 >= 1) {
- vetor[soma1-1] = 1;
- soma1 = soma1 - salt; }
- }
- for(i=0; i<numpedras; i++) {
- printf("%d\n", vetor[i]); }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement