fork download
  1. #include <stdio.h>
  2.  
  3. int pitch;
  4. int period () {
  5. static int count = 0;
  6. static int number = 0;
  7.  
  8. if (count>=pitch) {
  9. count = 0;
  10. number = 1 - number;
  11. }
  12. count++;
  13.  
  14. return number;
  15.  
  16. }
  17.  
  18. int main(void) {
  19. int n;
  20. int value;
  21. scanf("%d %d",&n,&pitch);
  22.  
  23. for (int i = 0; i < n; i++) {
  24. value = period();
  25. printf("%d",value);
  26. }
  27. printf("\n");
  28.  
  29. return 0;
  30. }
  31.  
Success #stdin #stdout 0.01s 5324KB
stdin
20 3
stdout
00011100011100011100