UVA 725 Division(除法)
输入正整数n,按从小到大的顺序输出所有形如abcde/fghij=n的表达式,其中a~j恰好为数字0~9的一个排列,2n
79。
题解:暴力破解枚举fghij。
#include
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;
const int maxn = 50000;
int main()
{
int kase=0;int a[5], b[5];int x = 0; while (cin >> x && x) {if(kase)cout<= 100000)break;int tx = to;for (int z = 0; z < 5; z++) {b[z] = tx % 10; tx /= 10;}isequal = false;for (int z = 0; z < 5; z++) {for (int j = z + 1; j < 5; j++) {for (int r = 0; r < 5; r++)if (b[z] == a[r] || b[j] == a[r]) {isequal = true; break;}if (b[z] == b[j]) {isequal = true; break;}}}if (isequal)continue;/*cout << to << " / " << right << setw(5) << setfill('0') << i << " = " << x << endl;*/printf("%05d / %05d = %d\n", to, i, x);iscout = true;}if (!iscout)printf("There are no solutions for %d.\n", x);}//system("pause");return 0;
}
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!
