Hello, there is a question on one problem. Maybe someone can help solve?

Problem: given three integers A, B, C Determine whether there is at least one even and at least one odd among them. Numbers A, B, C , not exceeding modulo 10,000. The format of the output. One line - "YES" or "NO".

 program Main; var a, b, c: longint; begin readln(a, b, c); if (a < abs(10000)) or (b < abs(10000)) or (c < abs(10000)) then begin if (not odd(a) or not odd(b) or not odd(c)) then writeln('YES') else if odd(a) or odd(b) or odd(c) then writeln('NO') end else writeln('input error!') end. 

That's what happened for me so far, the decision was partially correct in the end (according to the test system) :(

Oh yeah, there is another task that I don’t understand how to solve at all:

Given the number X. Required to translate this number in the Roman number system. Input file format: Given the number X in decimal notation (1 ≤ X ≤ 100). Output file format: Output X in the Roman numeral system.

It’s not necessary to write the decision completely, I basically imagine how to solve it (probably with the help of the case ), but bad luck, I don’t know Roman numerals at all :(

  • one
    Not exceeding 10,000: X <= 10000 . That's wrong. - karmadro4

4 answers 4

Either rewrite the condition in the forehead, with an enumeration of all pairs of variables, or reduce:

 if odd(a+b) and odd(a+c) and odd(b+c)) then writeln('NO') else writeln('YES') 

    but bad luck, I absolutely do not know the Roman numerals: (

    Roman numbers are constructed from the numbers I (1), V (5), X (10), L (50), C (100), D (500), M (1000). Rules:
    1) When recording numbers from higher to lower weight, numbers are summarized.

     Пример: LXXVI = 76 

    2) When writing a digit with a lower weight, before a digit with a larger weight, the weight of the first (subtractor) is subtracted from the weight of the second

     Пример: IX = 9 

    3) Two or more subtractors in a row are not allowed.

     Пример: IIX = ошибка 

    4) Other things being equal, a shorter recording is selected.

     Пример: IX, а не VIIII 

    There are a lot of modifications of the rules (there is no single standard). For example, in some systems of rules a subtractor of 5, 50, 500 (IV, XL) is allowed, in some - not (IIII, XXXX). In general, most of the rule systems for writing Roman numbers were formed in the Middle Ages;)

    PS I wanted a comment, not an answer, but did not keep up :)

    • 3
      It seems that the hashcode turns into a forum for duplicates and idiots. Although what can be expected from a modern education system? - skegg

    Here I fixed the code, it seems to work:

     program main; var a, b, c: longint; begin readln(a, b, c); if (a < abs(10000)) And (b < abs(10000)) And (c < abs(10000)) then begin If ((Odd(a) And (Not Odd(b) Or Not Odd(c))) Or (Odd(b) And (Not Odd(a) Or Not Odd(c))) Or (Odd(c) And (Not Odd(a) Or Not Odd(b)))) Then WriteLn('YES') Else WriteLn('NO'); end else writeln('input error!'); ReadLn; end. 

    The solution of the second problem, as I recall, can be found in the textbook of S. A. Nemnyugin "Pascal Programming in a High-Level Language".

    • In your condition it is checked whether at least one of the numbers is even, and the back ones - one even and one odd. - renegator
    • Yes, I looked at the task inattentively. Now fixed, it works as it should. - DelphiM0ZG

    write on stupid:

    make two variables k1 , k2 - k1 it will be the number of odd, and k2 number of even.

    Then 3 if'a to test an example:

     if (a mod 2=0) then k2:=k2+1 else k1:=k1+1; 

    and so for b and c , then check:

     if ((k1<>0) and (k2<>0)) then write('YES') else write('NO'); 

    and do not forget to reset k1 and k2 .

    • Round, why? The logical continuation is an array and a loop. - karmadro4
    • The remaining one counter, which is checked for equality 1 or 2 (then YES). Damn, the question is already six months. Not relevant. - avp
    • Pascal variables are not rounded at the beginning, but this may affect the answer - VadRus
    • one
      > in Pascal, the variables at the beginning are not rounded I do not understand. Everything is considered in the field of integers and rounding does not make sense. - karmadro4
    • pancake. I am confused to reset and round off - VadRus