作者:txy001美丽人生_618 | 来源:互联网 | 2024-10-09 20:34
简单的暴力题,由于数规模固定,把所有情况考虑到就好了。
/*
ID: ljracm1
LANG: C++
PROB: crypt1
*/
#include
#include
#include
#define Tusing namespace std;int vis[12],n;bool judge(int num){while(num){int d=num%10;if(!vis[d])return false;num/=10;}return true;
}int main(){#ifdef Tfreopen("crypt1.in","r",stdin);freopen("crypt1.out","w",stdout);#endifmemset(vis,0,sizeof(vis));cin>>n;for(int i&#61;0; i>num;vis[num]&#61;1;}int ans&#61;0;for(int a&#61;1; a<&#61;9; a&#43;&#43;){if(!vis[a])continue;for(int b&#61;1; b<&#61;9; b&#43;&#43;){if(!vis[b])continue;for(int c&#61;1; c<&#61;9; c&#43;&#43;){if(!vis[c])continue;for(int x&#61;1; x<&#61;9; x&#43;&#43;){if(!vis[x])continue;for(int y&#61;1; y<&#61;9; y&#43;&#43;){if(!vis[y])continue;int tem &#61; a*100&#43;b*10&#43;c;int sum1 &#61; tem*x;int sum2 &#61; tem*y;if(sum1>999||sum2>999)continue;if(sum1&#43;sum2*10>9999)continue;if(judge(sum1)&&judge(sum2)&&judge(sum1&#43;sum2*10)){#ifndef Tcout<}