Tuesday, January 21, 2020

Codeforces 158A Next Round Solution in C



  1. #include<stdio.h>
  2. int main()
  3. {
  4. int a,i,b,c,x,y,n;
  5. scanf("%d %d",&a,&b);
  6. i=0;
  7. n=0;
  8. y=0;
  9. while (i<a)
  10. {
  11. scanf("%d",&x);
  12. if (i<b && x!=0)
  13. {
  14. n++;
  15. y=x;
  16. }
  17. else if (y==x && x>0) n++;
  18. i++;
  19. }
  20. printf("%d\n",n);
  21. return 0;
  22. }

No comments:

Post a Comment

Codeforces 131A cAPS lOCK Solution in C

#include <stdio.h> int main () { char ch [ 106 ]; int i , j , ck = 1 ; scanf ( "%s" , ch ); ...