|
|
вернуться в форумwhy my program is wrong ?! program conductor; var q,p,p1,q1:real; i:integer; begin readln(p,q); for i:=1 to 11000 do begin p1:=trunc((i*p)/100); q1:=trunc((i*q)/100); if (q1-p1)>0 then begin writeln(i); exit; end; end; end. I found Dear BEHRANG. Hi dear Behrang at first welcome to Timus Iranian Programmers! and then for getting Ac on 1011: Insert this line at point I refered: ---> if frac(q1)=0 then q1:=q1-1 else q1:=trunc(q1); and delete trunc on ---> q1=trunc((i*q)/100); so... ~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~ > program conductor; > var > q,p,p1,q1:real; > i:integer; > begin > readln(p,q); > for i:=1 to 11000 do > begin > p1:=trunc((i*p)/100); > q1:=trunc((i*q)/100); (* insert my hint here (if line) so you will got AC *) > if (q1-p1)>0 then > begin > writeln(i); > exit; > end; > end; > end. ~~~~~~~~~~~~~ will be : var q,p,p1,q1:real; i:integer; begin readln(p,q); for i:=1 to 11000 do begin p1:=trunc((i*p)/100); q1:=(i*q)/100; if frac(q1)=0 then q1:=q1-1 else q1:=trunc(q1); if (q1-p1)>0 then begin writeln(i); exit; end; end; end. Best Aidin_n7@hotmail.com |
|
|