38 lines
707 B
C
38 lines
707 B
C
|
#include <stdio.h>
|
||
|
#include <stdlib.h>
|
||
|
#include <string.h>
|
||
|
|
||
|
int get_prio (char c) {
|
||
|
int r = (int) (c - 'a'+1);
|
||
|
if (r > 0) return r;
|
||
|
return r + 'A' - 7;
|
||
|
}
|
||
|
|
||
|
int main () {
|
||
|
char cur[50];
|
||
|
int half = 0;
|
||
|
u_int64_t mask = 0;
|
||
|
int sum = 0;
|
||
|
|
||
|
while (fgets(cur,50,stdin) != NULL) {
|
||
|
int i;
|
||
|
half = strlen(cur) / 2;
|
||
|
for (i = 0; i<half; i++) {
|
||
|
//printf("%c %d\n", cur[i], get_prio(cur[i]));
|
||
|
mask |= (1LL << get_prio(cur[i]));
|
||
|
}
|
||
|
//printf("half!\n");
|
||
|
for (i=half; i<strlen(cur)-1; i++) {
|
||
|
//printf("%c %d\n", cur[i], get_prio(cur[i]));
|
||
|
if (mask & (1LL << get_prio(cur[i]))) {
|
||
|
// printf("%c", cur[i]);
|
||
|
sum += get_prio(cur[i]);
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
mask = 0;
|
||
|
}
|
||
|
printf("%d\n", sum);
|
||
|
|
||
|
}
|