Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- bool test;
- void solve(int n)
- {
- int abcde,fghij;
- for(fghij=1234; fghij<=98765/n; fghij++)
- {
- abcde = fghij*n;
- int temp,used = (fghij<10000);
- temp = fghij;
- while(temp)
- {
- used |= 1<<(temp%10);
- temp/=10;
- }
- temp = abcde;
- while(temp)
- {
- used |= 1<<(temp%10);
- temp/=10;
- }
- if(used == (1<<10)-1)
- {
- printf("%0.5d / %0.5d = %d\n",abcde,fghij,n);
- test = true;
- }
- }
- return;
- }
- int main()
- {
- int n,pre=-1;
- while(scanf("%d",&n)&&n)
- {
- if(pre!=n && pre!=-1)
- {
- puts("");
- }
- test = false;
- solve(n);
- if(!test)
- {
- printf("There are no solutions for %d.\n",n);
- }
- pre = n;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment