blob: 793396cb4d98d96c7a55c33dce7cf90477de46ad (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
#include <stdio.h>
#include <stdlib.h>
int main(void) {
int valid1 = 0, valid2 = 0;
int l, u;
char c, p[256];
while (EOF != scanf("%d-%d %c: %s\n", &l, &u, &c, p)) {
int n = 0;
for (int i = 0; p[i]; ++i) {
if (p[i] == c) n++;
}
if (n >= l && n <= u) valid1++;
if ((p[l-1] == c) ^ (p[u-1] == c)) valid2++;
}
printf("%d\n", valid1);
printf("%d\n", valid2);
}
|