#Help me

21 messages · Page 1 of 1 (latest)

faint fog
#

C Language

frosty cipherBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

undone patio
#

why do you expect it to be that?

#

when you input 101010101010 111010101011 34359738368 those 3 assign to N, M, and F respectively

#

N ^ (M + 1) is 61674906630

#

61674906630 is larger than 34359738368

#

so K <= F is false

#

and therefore if (can_save) goes to the else

#

I think you might be confused by N and M

#

they dont take in binary numbers just because you write them as 1s and 0s

quasi kestrel
#

!f

frosty cipherBOT
#
int main() {
  unsigned long long N, M, F, K;
  int can_save = 0;

  scanf("%llu %llu %llu", &N, &M, &F);

  if (N == 0) {
    can_save = (M == 0);
  } else {
    K = N ^ (M + 1);
    can_save = (K <= F);
  }

  if (can_save) {
    printf("HAHAHA, I CAN SAVE THE WORLD\n");
  } else {
    printf("OH NOOO, I FAILED\n");
  }

  return 0;
}

Guys, why if i input 101010101010 111010101011 34359738368, the output is OH NOOO, I FAILED. Whereas, it should be HAHAHA, I CAN SAVE THE WORLD. Can you guys tell me where the problem is ? and modified my program.

ZANZ
faint fog
#

the question is like this, would you please do me a favour ?

undone patio
#

you would need to parse N and M from their binary representations

#

currently you're parsing them as decimals

#

there is no binary format for scanf unfortunately

#

so you need to parse it from the string in a different way

faint fog
#

Aahh i see

#

i just solve the problem, thank you bro

#

!solve