Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- int main()
- {
- FILE* fp;
- fp = fopen("testdata.in", "r");
- int testcase;
- fscanf(fp, "%d", &testcase);
- for(int tc = 1; tc<=testcase; tc++)
- {
- int count;
- int lightning;
- int seq, min, max;
- fscanf(fp, "%d %d %d", &seq, &min, &max);
- for(int i = 0; i<seq; i++)
- {
- char bin;
- fscanf(fp, "%c", &bin);
- if(bin == '1') count++;
- if(bin == '0')
- {
- if(count<= max && count >= min)
- lightning++;
- }
- count = 0;
- }
- printf("Case #%d: %d\n", tc, lightning);
- }
- fclose(fp);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement