fork download
  1. program solitario;
  2. var N,M,a:longint;
  3.  
  4. begin
  5. (*assign(input, 'input.txt'); reset(input);
  6.   assign(output, 'output.txt'); rewrite(output);*)
  7. readln(N,M);
  8. if M<N then begin a:=N; N:=M; M:=a; end;
  9. if (N<=2) or ((N=3) and (M=3)) then writeln(N* (M-(M div 3)))
  10. else
  11. if N*M >25 then writeln(N*M*11 div 20+1)
  12. else if N=3 then writeln (N*M*2 div 3 - M div 3 )
  13. else if (N=4) and( M mod 3 =0 ) then writeln((N-1)* (M-(M div 3))+1)
  14. else writeln((N-1)* (M-(M div 3)));
  15.  
  16. end.
Success #stdin #stdout 0.01s 5284KB
stdin
4 6
stdout
13