14a.c (335B)
1 #include <stdio.h> 2 3 #define N 102 4 5 char line[N]; 6 int i, j, t, s[N], r[N]; 7 8 int main() { 9 for (i = 0; fgets(line, N, stdin) != NULL; i++) { 10 for (j = 0; line[j] != '\n'; j++) { 11 if (line[j] == '#') s[j] = i+1; 12 if (line[j] == 'O') r[s[j]++]++; 13 } 14 } 15 for (j = 0; j < i; j++) 16 t += r[j] * (i-j); 17 18 printf("%d\n", t); 19 return 0; 20 }