#include<bits/stdc++.h> using namespace std; int main() { int n; bool first = true; while(cin >> n && n){ if(first){ first = false; }else printf("\n"); bool ok = false; for(int i = 1234; i <= 98765; i++){ //0作为x的前导0,因此全部数为1-9 int x = i, y = x*n; if(y / 10000 < 1 || y / 10000 > 9){ continue; } set<int>s; while(x){ s.insert(x % 10); x /= 10; } while(y){ s.insert(y % 10); y /= 10; } if(i < 10000 && s.size() == 9 && *s.begin() != 0){ ok = true; printf("%d / 0%d = %d\n", i*n, i, n); } if(i > 10000 && s.size() == 10){ ok = true; printf("%d / %d = %d\n", i*n, i, n); } } if(!ok){ printf("There are no solutions for %d.\n", n); } } return 0; }
原文:https://www.cnblogs.com/sanshi-2018/p/10446876.html