|
|
back to boardWhy WA#7??? {Почему WA#7???} label a1; var n, m, r, nn, mn, nm, mm: longint; begin read(n, m); if m > n then begin r := m; m := n; n := r; end; nn := round(int(sqrt(n - 1))); mn := round(int(sqrt(m - 1))); if nn = mn then begin nm := n - nn * nn; mm := m - mn * mn; r := abs(mm - nm); goto a1; end; r := nn - mn; r := r * 2; r := r - 1; nm := n - nn * nn; mm := m - mn * mn; if m mod 2 - mn mod 2 = 0 then r := r + 1; if abs(n mod 2 - nn mod 2) = 1 then r := r + 1; if (nm - mm > nn - mn + 1) then r := r + ((abs(nm - mm) - 1) div 2) * 2; if (mm - nm + 1 > nn - mn) then r := r + ((abs(nm - mm) + 1) div 2) * 2; a1: writeln(r); end. Edited by author 14.10.2005 20:52 |
|
|