|
|
вернуться в форумWhy I am Wrong,please help me. program ex; const maxn=20; var i,n:longint; flag:boolean; z:integer; a:array[1..maxn]of byte; function check(x:longint):boolean; var i:longint; begin check:=true; for i:=2 to trunc(sqrt(x)) do if x mod i=0 then begin if i>10 then begin writeln(-1); halt; end; check:=false; exit; end; end; procedure solve(x:longint); var i:integer; begin if check(x) then if x<10 then begin z:=z+1; a[z]:=x; exit; end else begin writeln(-1); halt; end; for i:=9 downto 2 do if x mod i=0 then begin flag:=false; z:=z+1; a[z]:=i; x:=x div i; solve(x); break; end; end; begin readln(n); flag:=true; fillchar(a,sizeof(a),0); z:=0; if n=0 then writeln(10) else if (n>=1) and (n<=9) then writeln(n) else begin solve(n); for i:=z downto 1 do write(a[i]); end; writeln; end. Re: Why I am Wrong,please help me. your program prints 1 sometimes.. for example the tests 252 - the answer is 479 you print 1479 72 - the answer is 89 you print 189 good luck. |
|
|