标签:
题目链接: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=666
/* UVa 725 Division --- 简单枚举 */ #include <cstdio> #include <cstring> bool used[10]; /* 判断传进来的两个数是否满足条件 */ bool judge(int a, int b) { if (a > 98765) return 0; memset(used, 0, sizeof used); if (b < 10000) used[0] = 1; while (b){ used[b % 10] = 1; b /= 10; } while (a){ used[a % 10] = 1; a /= 10; } int sum = 0; for (int i = 0; i < 10; ++i) sum += used[i]; return sum == 10; } int main() { int n, kase = 0; while (scanf("%d", &n)== 1 && n){ if (kase++){ printf("\n"); } int cnt = 0; for (int i = 1234; i <= 54321; ++i){ if (judge(i*n, i)){ printf("%05d / %05d = %d\n", i*n, i, n); ++cnt; } }//for(i) if (cnt == 0){ printf("There are no solutions for %d.\n", n); } } return 0; }
标签:
原文地址:http://www.cnblogs.com/tommychok/p/5055021.html