#include<cstdio> #include<cstring> #include<algorithm> #include<cstdlib> #include<iostream> #include<queue> #include<vector> #include<sstream> using namespace std; int a[10]; int main(){ int n, kase = 0; bool OK = false; while(scanf("%d", &n) == 1 && n) { if(kase++) printf("\n"); bool OK = false; for(int x1 = 0; x1 < 10;x1++) for(int x2 = 0; x2 < 10;x2++) for(int x3 = 0; x3 < 10;x3++) for(int x4 = 0; x4 < 10;x4++) for(int x5 = 0; x5 < 10; x5++){ memset(a,0,sizeof(a)); if(a[x1] == 0) a[x1]++; else continue; if(a[x2] == 0) a[x2]++; else continue; if(a[x3] == 0) a[x3]++; else continue; if(a[x4] == 0) a[x4]++; else continue; if(a[x5] == 0) a[x5]++; else continue; int p = (x1*10000+x2*1000+x3*100+x4*10+x5); int q = p * n; if(q > 98765) continue; bool ok = true; int t = 5; while(t--){ if( a[q%10] != 0 ) {ok = false; break;} else a[q%10]++ ; q = q / 10; } if(ok) {printf("%05d / %05d = %d\n", p*n, p, n);OK = true;} } if(!OK) printf("There are no solutions for %d.\n",n); } return 0; }
uva 725
猜你喜欢
转载自blog.csdn.net/a874288174/article/details/79858523
今日推荐
周排行