Advertisement
Raul_julian

Pulo_do_sapo-[OBI]

Jun 18th, 2013
392
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.66 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main() {
  4.  
  5.     int i, numsapo, numpedras;
  6.  
  7.     scanf("%d %d", &numpedras, &numsapo);
  8.  
  9.     int vetor[numpedras], position, salt, soma, soma1;
  10.  
  11.    
  12.  
  13.     for(i=0; i<numpedras; i++) vetor[i] = 0;
  14.  
  15.     for(i=1; i<=numsapo; i++) {
  16.  
  17.         scanf("%d %d", &position, &salt);
  18.  
  19.         if(position != 0) vetor[position-1] = 1;
  20.        
  21.             soma = position+salt;
  22.             soma1 = position-salt;
  23.  
  24.         while(soma <= numpedras) {
  25.  
  26.             vetor[soma-1] = 1;
  27.             soma = soma + salt; }
  28.        
  29.         while(soma1 >= 1) {
  30.  
  31.             vetor[soma1-1] = 1;
  32.             soma1 = soma1 - salt; }
  33.            
  34.             }
  35.  
  36.  
  37.     for(i=0; i<numpedras; i++) {
  38.  
  39.         printf("%d\n", vetor[i]); }
  40.  
  41.  
  42.     return 0;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement