725 - Division

All about problems in Volume 7. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 725 - Division

Post by brianfry713 »

input:

Code: Select all

2
0
Output should be:

Code: Select all

13458 / 06729 = 2
13584 / 06792 = 2
13854 / 06927 = 2
14538 / 07269 = 2
14586 / 07293 = 2
14658 / 07329 = 2
15384 / 07692 = 2
15846 / 07923 = 2
15864 / 07932 = 2
18534 / 09267 = 2
18546 / 09273 = 2
18654 / 09327 = 2
26970 / 13485 = 2
27096 / 13548 = 2
27690 / 13845 = 2
29076 / 14538 = 2
29370 / 14685 = 2
29670 / 14835 = 2
29706 / 14853 = 2
29730 / 14865 = 2
30972 / 15486 = 2
32970 / 16485 = 2
37092 / 18546 = 2
37290 / 18645 = 2
41358 / 20679 = 2
41538 / 20769 = 2
41586 / 20793 = 2
46158 / 23079 = 2
53418 / 26709 = 2
53814 / 26907 = 2
54138 / 27069 = 2
54186 / 27093 = 2
54618 / 27309 = 2
58134 / 29067 = 2
58146 / 29073 = 2
58614 / 29307 = 2
61458 / 30729 = 2
61584 / 30792 = 2
61854 / 30927 = 2
62970 / 31485 = 2
64158 / 32079 = 2
65418 / 32709 = 2
65814 / 32907 = 2
69702 / 34851 = 2
70296 / 35148 = 2
70962 / 35481 = 2
76290 / 38145 = 2
76902 / 38451 = 2
90276 / 45138 = 2
90372 / 45186 = 2
90762 / 45381 = 2
92370 / 46185 = 2
93702 / 46851 = 2
96270 / 48135 = 2
96702 / 48351 = 2
97026 / 48513 = 2
97032 / 48516 = 2
97062 / 48531 = 2
97230 / 48615 = 2
97302 / 48651 = 2
Check input and AC output for thousands of problems on uDebug!
Yusif
New poster
Posts: 27
Joined: Tue Jun 25, 2013 2:24 am

Re: 725 - Division

Post by Yusif »

stupid of me! :P

thanks a lot!!
kp25
New poster
Posts: 2
Joined: Sat Apr 28, 2012 7:16 pm

Re: 725 - Division

Post by kp25 »

WA always, What is the error..?
Could any point me out the test cases.?

Code: Select all

#include <cstdio>

int main() {
	int N, flag, kase = 0;
	while(scanf("%d",&N) && N) {
		if(kase) printf("\n\n"); kase++;

		flag = 0;
		for(int fghij = 1234; fghij <= 98765/N; fghij++) {
			int abcde = N * fghij;
			int tmp, used = (fghij < 10000);
			
			tmp = abcde; while(tmp) { used |= 1 << (tmp%10); tmp /= 10; }
			tmp = fghij; while(tmp) { used |= 1 << (tmp%10); tmp /= 10; }
			if(used == (1<<10)-1) {
				if(flag) printf("\n");
				printf("%0.5d / %0.5d = %d", abcde, fghij, N); flag = 1;
			}
		}
		if(!flag) printf("There are no solutions for %d.", N);
	}
	return 0;
}
brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 725 - Division

Post by brianfry713 »

It looks like you figured it out
Check input and AC output for thousands of problems on uDebug!
ssaha22
New poster
Posts: 5
Joined: Sat Dec 14, 2013 10:00 am

Re: 725 - Division

Post by ssaha22 »

whats wrong with this ?? :'(
i checked on udebug for almst 50 inputs...didnt find any wrong ... can ny1 help please?? :(

Code: Select all

#include <cstdio>
#include <vector>
#include <iostream>
#include <cstring>
#include <string>
#include <map>
using namespace std;
char s[20];
char r[20];
map <char,int>m;
class anst{
    public:
    int a;
    int b;
    int N;
};

int main(){
    int a,b=0,c,d,n,N;
    string S,R,T;
    while(1){
        cin>>N;
        if(N==0){
            break;
        }
        if(b!=0){
        cout<<endl;
        }
        b++;
        vector<anst>v;
        v.clear();
        memset(s,0,sizeof(s));
        memset(r,0,sizeof(r));

        for(c=1234;c<=98765/2;c++){
                if(c*N<=98765){

                    int ans=c*N;
                    sprintf(s,"%d",ans);
                    sprintf(r,"%d",c);
                    S=s;
                    R=r;
                    T=S+R;
                    int chk=0;
                    m.clear();
                    if(S.length()==4 || R.length()==4){
                        m['0']=1;
                    }
                    if(S.length()==4 && R.length()==4){
                        chk=-2;
                    }
                    for(a=0;a<T.length();a++){
                        if(m[T[a]]==1){
                            chk=-2;
                            break;
                        }
                        m[T[a]]=1;
                    }
                    if(chk==0){
                        anst y;
                        y.a=c;
                        y.b=ans;
                        y.N=N;
                        v.push_back(y);
                    }
                }
            }

        if(v.size()!=0){
            for(c=0;c<v.size();c++){
                if(v[c].a<=9999){
                    cout<<v[c].b<<" / 0"<<v[c].a<<" = "<<v[c].N<<endl;
                }
                else{
                cout<<v[c].b<<" / "<<v[c].a<<" = "<<v[c].N<<endl;
                }
            }
        }
        else{
            cout<<"There are no solutions for "<<N<<endl;
        }
    }
    return 0;
}
Last edited by brianfry713 on Mon Mar 30, 2015 11:57 pm, edited 1 time in total.
Reason: Added code block
Post Reply

Return to “Volume 7 (700-799)”