fork download
  1. #include <stdio.h>
  2. int p;
  3.  
  4. int period(){
  5. static int count=0;
  6. static int state=0;
  7. count++;
  8. if(count%p==0){
  9. state=1-state;
  10. }
  11. return state;
  12. }
  13.  
  14. int main(void) {
  15. int i,n;
  16. scanf("%d %d",&n,&p);
  17. for(i=0;i<n;i++)
  18. printf("%d",period());
  19. return 0;
  20. }
  21.  
Success #stdin #stdout 0s 5328KB
stdin
8 2
stdout
01100110