cryptarithm专题

usaco 1.3 Prime Cryptarithm(简单哈希表暴搜剪枝)

思路: 1. 用一个 hash[ ] 数组存放输入的数字,令 hash[ tmp ]=1 。 2. 一个自定义函数 check( ) ,检查各位是否为输入的数字。 3. 暴搜。第一行数从 100到999,第二行数从 10到99。 4. 剪枝。 代码: /*ID: who jayLANG: C++TASK: crypt1*/#include<stdio.h>bool h

1.3.4 Prime Cryptarithm

简单题…… #include<iostream>#include<fstream>using namespace std;int n;int number[10]={0};bool Judge(int num){int i, temp, flag;while( num>0 ){flag=0;temp=num%10;num/=10;for(i=0; i<

usaco Prime Cryptarithm

遍历就行了。题目没给清楚其实他数字的个数不超过9个也就是不存在相同的数字。 /*ID: jinbo wuLANG:C++TASK: crypt1*/ #include<bits/stdc++.h>using namespace std;int a[10];bool v[10];bool judge(int x){while(x){int t=x%10;if(!v[t])ret