1
0

TL1.PAS 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. var a:array[1..3] of longint;
  2. f:longint;
  3. i:integer;
  4. begin
  5. for i:=1 to 3 do read(a[i]);
  6. if a[1]>a[2] then
  7. begin
  8. if a[1]>a[3] then
  9. i:=1
  10. else
  11. i:=3;
  12. end
  13. else
  14. begin
  15. if a[3]>a[2] then
  16. i:=3
  17. else
  18. i:=2;
  19. end;
  20. f:=0;
  21. while true do
  22. begin
  23. case i of
  24. 1:begin
  25. if a[2]=a[3] then
  26. begin
  27. inc(f);break;
  28. end
  29. else
  30. if a[2]>a[3] then
  31. begin
  32. inc(f,2);a[1]:=a[2]-a[3];i:=2;
  33. end
  34. else
  35. begin
  36. inc(f);a[1]:=a[3]-a[2];i:=3;
  37. end;
  38. end;
  39. 2:begin
  40. if a[1]=a[3] then
  41. begin
  42. inc(f,2);break;
  43. end
  44. else
  45. if a[1]>a[3] then
  46. begin
  47. inc(f);a[2]:=a[1]-a[3];i:=1;
  48. end
  49. else
  50. begin
  51. inc(f,2);a[2]:=a[3]-a[1];i:=3;
  52. end;
  53. end;
  54. 3:begin
  55. if a[1]=a[2] then
  56. begin
  57. inc(f,3);break;
  58. end
  59. else
  60. if a[1]>a[2] then
  61. begin
  62. inc(f,2);a[3]:=a[1]-a[2];i:=1;
  63. end
  64. else
  65. begin
  66. inc(f);a[3]:=a[2]-a[1];i:=2;
  67. end;
  68. end;
  69. end;
  70. end;
  71. i:=f mod 3;
  72. if i=0 then i:=3;
  73. writeln('The student ',i,' can guess his number at round ',f);
  74. end.