Description
Write a program, finds and displays all pairs of 5-digit numbers, between them use the digits 0 through C1>9 once each, such the first number divided by the second are equal to an integer N, where. That's,
Abcde/fghij = N
Where each letter represents a different digit. The first digit of the numerals is allowed to be zero.
InputEach line of the input file consists of a valid integer
N. An input of zero was to terminate the program.
OutputYour program has to display all qualifying pairs of numerals, sorted by increasing numerator (and, of course, denominator ).
Your output should is in the following general form:
xxxxx/xxxxx = N
xxxxx/xxxxx = N
.
.
In case there is no pairs of numerals satisfying the condition, you must write 'there is no solutions for N.". Separate the output for both different values of N by a blank line.
Sample Input
61620
Sample Output
There is no solutions for 61.79546/01283 = 6294736/01528 = 62
Miguel Revilla
2000-08-31From 1234 to 99999 enumerate over again on the line.
#include <stdio.h>intnumber[ the];intCheckintAintb) { if(A >98765)return 0; for(intI=0;i<Ten; i++) {Number[i]=0; } if(b<10000) number[0] =1; while(a) {Number[a%Ten] =1; A/=Ten; } while(b) {number[b%Ten] =1; b/=Ten; } intsum =0; for(intI=0; i<Ten; i++) Sum+=Number[i]; returnsum = =Ten;}intMain () {intans, cnt =0; while(SCANF ("%d", &ans) = =1, ans) { if(cnt++) printf ("\ n"); intFlag =0; for(inti =1234;i<99999; i++){ if(Check (i*ans,i)) {printf ("%05d/%05d =%d\n"Ians, I, ans); Flag=1; } } if(!flag) {printf ("There is no solutions for%d.\n", ans); } } return 0;}
View Code
UVA 725–division