fork download
  1. #include<iostream>
  2.  
  3. char*m="02210313074020029000033739";
  4. int f(char*p){int n=0;while(*p)n+=m[*p++-65]-47;return n;}
  5.  
  6. int main() {
  7. std::cout << f("ABC") << std::endl;
  8. std::cout << f("PPCG") << std::endl;
  9. std::cout << f("STEWIE") << std::endl;
  10. std::cout << f("FIZZBUZZ") << std::endl;
  11. std::cout << f("ABCDEFGHIJKLMNOPQRSTUVWXYZ") << std::endl;
  12. return 0;
  13. }
Success #stdin #stdout 0s 4476KB
stdin
Standard input is empty
stdout
7
11
9
49
87