记录编号 175489 评测结果 AAAAAAA
题目名称 牛式 最终得分 100
用户昵称 Gravatar啊吧啦吧啦吧 是否通过 通过
代码语言 C++ 运行时间 0.010 s
提交时间 2015-08-06 07:08:30 内存使用 0.31 MiB
显示代码纯文本
/*
ID: jhqwan1
PROG: crypt1
LANG: C++11
*/
#include <fstream>
#include <iostream>

using namespace std;

int n, s[10], a, b, c, d, e, ans = 0;
ifstream fin("crypt1.in");
ofstream fout("crypt1.out");
#define cin fin
#define cout fout
bool yes;
inline void bao();

main()
{
	cin >> n;
	for (int i = 1; i <= n; ++i)
		cin >> s[i];
	
	bao();
	
	cout << ans;
//	for(;;);
}

inline void bao(){
	for (int i = 1; i <= n; ++i)
		for (int j = 1; j <= n; ++j)
			for (int k = 1; k <= n; ++k){
				a = s[i] * 100 + s[j] * 10 + s[k];
				for (int l = 1; l <= n; ++l)
					for (int m = 1; m <= n; ++m){
						yes = 1;
						b = s[l] * 10 + s[m];
						c = a * (b % 10);
						if (c < 100 || c > 999)
							continue;
						while (c > 0){
							d = c % 10;
							c /= 10;
							int o;
							for (o = 1; o <= n; ++o)
								if (d == s[o])
									break;
							if (o > n){
								yes = 0;
								break;
							}
						}
						if (! yes)
							continue;
						d = a * (b / 10);
						if (d < 100 || d > 999)
							continue;
						while (d > 0){
							e = d % 10;
							d /= 10;
							int o;
							for (o = 1; o <= n; ++o)
								if (e == s[o])
									break;
							if (o > n){
								yes = 0;
								break;
							}
						}
						if (! yes)
							continue;
						e = a * b;
						if (e < 1000 || e > 9999)
							continue;
						while (e > 0){
							c = e % 10;
							e /= 10;
							int o;
							for (o = 1; o <= n; ++o)
								if (c == s[o])
									break;
							if (o > n){
								yes = 0;
								break;
							}
						}
						if (! yes)
							continue;
						ans++;
					}
			}
}