|
|
вернуться в форумNeed help for problem 1011 : Conductors Could someone give me some hints for problem 1011. I can pass the test case but keep getting WA. Looks like there is a test case that the program can not pass. I past the tast case too Here s my algo i=0 while not found solution do i=i+1 if trunc(i*inputted1)<>trunc(i*inputted2) then found solution=true output(i) That's all. I'm perfectly sure it's correct, I've submitted it in Pascal as well as in C++, but I got C++(in C++ instead of trunc I use floor). Do you do the same? pass the tast case too, mistakes corrected Oops, i made some mistakes. I meant Here s my algo i=0 while not found solution do i=i+1 if trunc(i*inputted1/100)<>trunc(i*inputted2/100) then found solution=true output(i)
That's all. I'm perfectly sure it's correct, I've submitted it in Pascal as well as in C++, but I got C++(in C++ instead of trunc I use floor). Do you do the same? Always WA > That's all. I'm perfectly sure it's correct, I've > submitted > it in Pascal as well as in C++, but I got C++(in C++ > instead of trunc I use floor). Do you do the same? I did the same thing but always got WA: program pr1011_conductors; var sol : integer; pct1, pct2 : real; found : boolean; begin found:=false; sol:=0; read(pct1,pct2); while not found do begin inc(sol); if trunc(sol*pct1/100) <> trunc(sol*pct2/100) then found:=true; end; writeln(sol); end. Re HA-HA My code is EXACTLY the same only the variable names differ from yours. BUT I haven't been ever more sure that program is correct. THERE'S JUST NO PLACE TO GET WRONG. So, as someone said in this forum but stopped helping : In Pascal, Real TYPE can be round, and it make incorrect. Use ROUND Function to fix it. If it still get WA, Call me. Do you get this? Cause I can't.. Too bad English or what? Re > In Pascal, Real TYPE can be round, and it make incorrect. > Use ROUND Function to fix it. > If it still get WA, Call me. > > Do you get this? Cause I can't.. Too bad English or what? I do not understand either. I also have tried with: trunc(....) - trunc(...) > 1E-15 but still get the same result. Re > > In Pascal, Real TYPE can be round, and it make incorrect. > > Use ROUND Function to fix it. > > If it still get WA, Call me. > > > > Do you get this? Cause I can't.. Too bad English or what? > I do not understand either. I also have tried with: > trunc(....) - trunc(...) > 1E-15 but still get the same > result. Pay attention to the fact that P and Q are STRICT estimations! |
|
|