Different answers on addition

Правка en1, от checknmate, 2025-01-01 08:33:19

Can anybody help why using the expression :

  • int x = ((2*b-c)%a) + ((2*b-c) < a) give different answer as compared to :

  • int x = ((2*b-c)%a!=0) + ((2*b-c) < a)

Problem reference : 1624B - Make AP

What I am trying is that x will be 0 if the 2*b-c is divisible by a and second condition is fulfilled (2*b-c < a) but the solution is accepted when I write a boolean expression and not when I directly use modulo value

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский checknmate 2025-01-01 08:33:19 460 Initial revision (published)