Language: C++

#include <iostream>
#include <vector>
#include <string>
using namespace std;
#define INF 1e9
int Eq[27], Zero[27];
vector<int> TC, hash, zr;

int check(){
	int sum=0;
	int i;
	for(i=0;i<int(hash.size());i++){
		sum += hash[i] * TC[i];
	}
	return sum ? 0 : 1;
}

int solve(){
	int i, j, sum = 0;
	if(hash.size() == TC.size()) return check();
	for(i=0;i<=9;i++){
		if(!i && zr[TC.size()]) continue;
		for(j=0;j<int(TC.size());j++) if(i==TC[j]) break;
		if(j<int(TC.size())) continue;
		TC.push_back(i);
		sum += solve();
		TC.pop_back();
	}
	return sum;
}

main(){
	int n, i;
	char buf[10];
	while(cin>>n,n){
		for(i=0;i<26;i++){
			Eq[i] = INF;
			Zero[i] = 0;
		}
		hash.clear();
		zr.clear();
		TC.clear();
		while(n--){
			cin>>buf;
			if(buf[1]) Zero[buf[0]-'A'] = 1;
			strrev(buf);
			for(i=0;buf[i];i++){
				if(Eq[buf[i]-'A'] == INF) Eq[buf[i]-'A'] = pow(10, i) * (n?1:-1);
				else Eq[buf[i]-'A'] += pow(10, i) * (n?1:-1);
			}
		}
		for(i=0;i<26;i++)if(Eq[i] != INF) hash.push_back(Eq[i]),zr.push_back(Zero[i]);
		cout << solve() << endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int check()':
a.cc:12:19: error: expected primary-expression before 'int'
   12 |         for(i=0;i<int(hash.size());i++){
      |                   ^~~
a.cc:12:19: error: expected ';' before 'int'
   12 |         for(i=0;i<int(hash.size());i++){
      |                   ^~~
      |                   ;
a.cc:12:19: error: expected primary-expression before 'int'
   12 |         for(i=0;i<int(hash.size());i++){
      |                   ^~~
a.cc:12:19: error: expected ')' before 'int'
   12 |         for(i=0;i<int(hash.size());i++){
      |            ~      ^~~
      |                   )
a.cc:12:19: error: expected primary-expression before 'int'
   12 |         for(i=0;i<int(hash.size());i++){
      |                   ^~~
a.cc:12:39: error: expected ';' before ')' token
   12 |         for(i=0;i<int(hash.size());i++){
      |                                       ^
      |                                       ;
a.cc: In function 'int solve()':
a.cc:20:12: error: reference to 'hash' is ambiguous
   20 |         if(hash.size() == TC.size()) return check();
      |            ^~~~
In file included from /usr/include/c++/14/string_view:50,
                 from /usr/include/c++/14/bits/basic_string.h:47,
                 from /usr/include/c++/14/string:54,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash'
   59 |     struct hash;
      |            ^~~~
a.cc:7:17: note:                 'std::vector<int> hash'
    7 | vector<int> TC, hash, zr;
      |                 ^~~~
a.cc: At global scope:
a.cc:32:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   32 | main(){
      | ^~~~
a.cc: In function 'int main()':
a.cc:40:17: error: reference to 'hash' is ambiguous
   40 |                 hash.clear();
      |                 ^~~~
/usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash'
   59 |     struct hash;
      |            ^~~~
a.cc:7:17: note:                 'std::vector<int> hash'
    7 | vector<int> TC, hash, zr;
      |                 ^~~~
a.cc:46:25: error: 'strrev' was not declared in this scope
   46 |                         strrev(buf);
      |                         ^~~~~~
a.cc:48:76: error: 'pow' was not declared in this scope
   48 |                                 if(Eq[buf[i]-'A'] == INF) Eq[buf[i]-'A'] = pow(10, i) * (n?1:-1);
      |                                                                            ^~~
a.cc:49:56: error: 'pow' was not declared in this scope
   49 |                                 else Eq[buf[i]-'A'] += pow(10, i) * (n?1:-1);
      |                                                        ^~~
a.cc:52:51: error: reference to 'hash' is ambiguous
   52 |                 for(i=0;i<26;i++)if(Eq[i] != INF) hash.push_back(Eq[i]),zr.push_back(Zero[i]);
      |                                                   ^~~~
/usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash'
   59 |     struct hash;
      |            ^~~~
a.cc:7:17: note:                 'std::vector<int> hash'
    7 | vector<int> TC, hash, zr;
      |                 ^~~~