Different answers on addition

Revision en1, by 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

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English checknmate 2025-01-01 08:33:19 460 Initial revision (published)