Try to think in terms of mathematics, trying to make accurate judgments what's the test case 7???? All the cases given hv been passed alr... I got WA4. Then i sorted answer by <length, int, int> and got AC. 800 5 725 + 75 = 800 728 + 72 = 800 730 + 70 = 800 750 + 50 = 800 800 + 00 = 800 100168 8 90584 + 9584 = 100168 91034 + 9134 = 100168 91059 + 9109 = 100168 91062 + 9106 = 100168 91064 + 9104 = 100168 91084 + 9084 = 100168 95084 + 5084 = 100168 100084 + 00084 = 100168 what is the ouput of the number 99 and 202 > what is the ouput of the number 99 and 202 The answer for 99 is: 1 90+9=99 the answer for 202 is: 5 151 + 51 = 202 184 + 18 = 202 186 + 16 = 202 191 + 11 = 202 201 + 01 = 202 Have a luck! :) If you want, write to me on e-mail: vladovasilev@abv.bg 200+02 > 200+02 It's wrong. Edited by author 09.06.2013 17:58 Can anybody help me with WA 4? My program passes all tests given in discuss... Silly mistake, as usually. Incorrect number of zeros. Try this test: 100 Answer: 3 91 + 9 = 100 95 + 5 = 100 100 + 00 = 100 Somebody can get "50 + 50 = 100". It's wrong by problem. =). Edited by author 16.10.2012 18:52 i don't know where could be wrong You can go from last digit to the first (the leftmost digit to the rightmost digit). For example : 302 Considering 2 : There are some possibilities: 0 + 2, 1 + 1, 2 + 0, 6 + 6, 5 + 7 ... (first operant is of the larger number, second operant is of the smaller number). Considering 0 : For each possibilities, you try to find out some possibilities that can be combined to produce 0 : 0 + 0... You can try any combinations to produce 0 if two operants used to produce 2 is equal, if they are different, you only have an only way, it reduce very much calculations). Considering 3 : The last digit, you can stop here and consider whether you have achieved a solution. why this don't suitable for the sample? It is not allowed to reorder digits I submitted several times but got TL#4. Where is my fault? var r,p,m,n,i:longint; kod:integer; j:shortint; q,s,t:string[10]; st:array [1..1000000] of string[50]; begin readln(n); str(n,q); r:=1; for i:=1 to length(q)-1 do r:=r*10; i:=n-r; repeat inc(i); str(i,s); j:=0; repeat inc(j); t:=s; delete(t,j,1); val(t,m,kod); if m+i=n then begin inc(p); st[p]:=s+' '+'+'+' '+t+' '+'='+' '+q; break; end; until j=length(s); until i=n; writeln(p); for i:=1 to p do writeln(st[i]); end. What's the min value of the first number. I mean it's min value according to N Edited by author 22.11.2007 14:40 Simple Problem. Just solve it. Go from last digits to first. Could anybody give out a test that let this program go wrong? Code: type ac=^acm; acm=record v1:longint; v2:longint; left,right:ac; end; var a,c:ac; b,d,e,f,g,h,i,j,k,l,m,n,s,p,r:longint; function mln(a:longint):extended; begin if a=0 then exit(a) else exit(ln(a)); end; procedure goal3(m,l,n:longint); var i,j,b,p:longint; procedure goal1(var a:ac); begin if a=nil then begin new(a); a^.left:=nil; a^.right:=nil; a^.v1:=b; a^.v2:=p; inc(s); end else if b=a^.v1 then else if b<a^.v1 then goal1(a^.left) else goal1(a^.right); end; begin j:=m div 11; i:=m-j; if i div 10=j then begin b:=i*l+n div 2; p:=j*l+n div 2; if trunc(mln(b)/mln(10))+1>trunc(mln(p)/mln(10))+1 then goal1(a); end; if (m div 10>0)and not odd(m mod 10) then goal3(m div 10,l*10,(m mod 10)*l+n); if (m div 10>1)and not odd(m mod 10) then goal3(m div 10-1,l*10,(m mod 10+10)*l+n); end; procedure goal2(a:ac); var i:longint; begin if a^.left<>nil then goal2(a^.left); if a<>nil then begin write(a^.v1,' + '); for i:=trunc(mln(a^.v2)/mln(10))+2 to trunc(mln(a^.v1)/mln(10)) do write('0'); writeln(a^.v2,' = ',k); end; if a^.right<>nil then goal2(a^.right); end; begin read(m); k:=m; s:=0; a:=nil; goal3(m,1,0); writeln(s); goal2(a); end. 'Crash (access violation)| 17| 0.015 |182 KB ',WHAT IS IT? I just can't understand! Could anybody give out a test that let this program go wrong? Code: type ac=^acm; acm=record v1:longint; v2:longint; left,right:ac; end; var a,c:ac; b,d,e,f,g,h,i,j,k,l,m,n,s,p,r:longint; function mln(a:longint):extended; begin if a=0 then exit(a) else exit(ln(a)); end; procedure goal3(m,l,n:longint); var i,j,b,p:longint; procedure goal1(var a:ac); begin if a=nil then begin new(a); a^.left:=nil; a^.right:=nil; a^.v1:=b; a^.v2:=p; inc(s); end else if b=a^.v1 then else if b<a^.v1 then goal1(a^.left) else goal1(a^.right); end; begin j:=m div 11; i:=m-j; if i div 10=j then begin b:=i*l+n div 2; p:=j*l+n div 2; if trunc(mln(b)/mln(10))+1>trunc(mln(p)/mln(10))+1 then goal1(a); end; if (m div 10>0)and not odd(m mod 10) then goal3(m div 10,l*10,(m mod 10)*l+n); if (m div 10>1)and not odd(m mod 10) then goal3(m div 10-1,l*10,(m mod 10+10)*l+n); end; procedure goal2(a:ac); var i:longint; begin if a^.left<>nil then goal2(a^.left); if a<>nil then begin write(a^.v1,' + '); for i:=trunc(mln(a^.v2)/mln(10))+2 to trunc(mln(a^.v1)/mln(10)) do write('0'); writeln(a^.v2,' = ',k); end; if a^.right<>nil then goal2(a^.right); end; begin read(m); k:=m; s:=0; a:=nil; goal3(m,1,0); writeln(s); goal2(a); end. Here are some tests: 10 1 10 + 0 = 10 21 0 43 0 100 3 91 + 9 = 100 95 + 5 = 100 100 + 00 = 100 4444 6 3722 + 722 = 4444 4022 + 422 = 4444 4037 + 407 = 4444 4040 + 404 = 4444 4042 + 402 = 4444 4222 + 222 = 4444 6667 1 6061 + 606 = 6667 6668 6 5834 + 834 = 6668 6034 + 634 = 6668 6059 + 609 = 6668 6062 + 606 = 6668 6064 + 604 = 6668 6334 + 334 = 6668 66667 1 60607 + 6060 = 66667 66668 7 58334 + 8334 = 66668 60334 + 6334 = 66668 60584 + 6084 = 66668 60604 + 6064 = 66668 60608 + 6060 = 66668 60634 + 6034 = 66668 63334 + 3334 = 66668 52525252 11 46262626 + 6262626 = 52525252 47747626 + 4777626 = 52525252 47750126 + 4775126 = 52525252 47750176 + 4775076 = 52525252 47750226 + 4775026 = 52525252 47750231 + 4775021 = 52525252 47752626 + 4772626 = 52525252 47762626 + 4762626 = 52525252 47812626 + 4712626 = 52525252 48262626 + 4262626 = 52525252 51262626 + 1262626 = 52525252 456000 10 378000 + 78000 = 456000 408000 + 48000 = 456000 413000 + 43000 = 456000 414500 + 41500 = 456000 414545 + 41455 = 456000 414546 + 41454 = 456000 414550 + 41450 = 456000 414600 + 41400 = 456000 415000 + 41000 = 456000 428000 + 28000 = 456000 123000321 1 111818474 + 11181847 = 123000321 200020002 16 150010001 + 50010001 = 200020002 181510001 + 18510001 = 200020002 181835001 + 18185001 = 200020002 181836351 + 18183651 = 200020002 181836366 + 18183636 = 200020002 181836371 + 18183631 = 200020002 181836401 + 18183601 = 200020002 181836501 + 18183501 = 200020002 181837001 + 18183001 = 200020002 181840001 + 18180001 = 200020002 181860001 + 18160001 = 200020002 181910001 + 18110001 = 200020002 182010001 + 18010001 = 200020002 185010001 + 15010001 = 200020002 190010001 + 10010001 = 200020002 200010001 + 00010001 = 200020002 1000000000 13 905000000 + 95000000 = 1000000000 909050000 + 90950000 = 1000000000 909090500 + 90909500 = 1000000000 909090905 + 90909095 = 1000000000 909090910 + 90909090 = 1000000000 909090950 + 90909050 = 1000000000 909091000 + 90909000 = 1000000000 909095000 + 90905000 = 1000000000 909100000 + 90900000 = 1000000000 909500000 + 90500000 = 1000000000 910000000 + 90000000 = 1000000000 950000000 + 50000000 = 1000000000 1000000000 + 000000000 = 1000000000 Wrong Answer with test 4. I don't know what happened. So who can help me with it? ------- 123456788 385358 945872567 5842375 ------- Thank you very much !!! Mail to dinhhongminh@yahoo.com who can write the answers here,Thanks In case anyone is interested (as the thread is ancient and the poster has probably got AC already), the results are: 123456788 8 106728394 + 16728394 = 123456788 111728394 + 11728394 = 123456788 112178394 + 11278394 = 123456788 112228394 + 11228394 = 123456788 112232894 + 11223894 = 123456788 112233394 + 11223394 = 123456788 112233439 + 11223349 = 123456788 112233444 + 11223344 = 123456788 --- 385358 10 292679 + 92679 = 385358 342679 + 42679 = 385358 347679 + 37679 = 385358 350179 + 35179 = 385358 350279 + 35079 = 385358 350319 + 35039 = 385358 350324 + 35034 = 385358 350326 + 35032 = 385358 350329 + 35029 = 385358 352679 + 32679 = 385358 -- 945872567 1 859884152 + 85988415 = 945872567 -- 5842375 1 5311250 + 531125 = 5842375 In BP7, I can run e.g test. But submit "Compilation Error". Why?. My code: mail : chungtq_2712@yahoo.com.vn [code deleted] Edited by moderator 08.06.2006 08:23 In FPC and Delphi "Result" is a standard variable for function result. Sure within function "Find" a variable "Result" has the same type as function, i.e. "bb", but not "li" despite the fact that there is a global variable "ReSult" of "li" type. P.S. And I have already told you to see FAQ for a guide how to investigate a reason of CE: http://acm.timus.ru/faq.aspxFirst, in one solution if you remove the last digit of the longer number, it will be the same as the shorter one. In this case the shorter one is (n div 11). Now if you force the last digits of both numbers are the same, it can only be (n div 2 mod 10) or (n div 2 mod 10+5). Store this as a suffix, cut the last digit off n, and do all above for the new but smaller n. I don't know if I have explained it clearly. If you still have questions, please mail maigoakisame@yahoo.com.cn input=800: 5 725 + 75 = 800 728 + 72 = 800 730 + 70 = 800 750 + 50 = 800 800 + 00 = 800 input=100168: 8 90584 + 9584 = 100168 91034 + 9134 = 100168 91059 + 9109 = 100168 91062 + 9106 = 100168 91064 + 9104 = 100168 91084 + 9084 = 100168 95084 + 5084 = 100168 100084 + 00084 = 100168 Good Luck! |
|