Advertisement
Joao_Joao

Beecrowd 1257 - C

May 22nd, 2022
838
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. #define f(i, s, t) for (int i = s; i < t; ++i)
  5.  
  6. int main() {
  7.   int t; scanf("%d", &t);
  8.   char p[55];
  9.   while(t--) {
  10.     int n; scanf("%d", &n);
  11.     int ans = 0;
  12.     f(i,0,n) {
  13.       scanf("%s", p);
  14.       f(j,0,strlen(p)) {
  15.         ans += i + j + (p[j]-'A');
  16.       }
  17.     }
  18.     printf("%d\n", ans);
  19.   }
  20. }
  21.  
Advertisement
RAW Paste Data Copied
Advertisement