×

# Ceil A-B ,What's wrong with my code ?

 0 //It's the code for Ceil A-B problem in practice set #include int main() { unsigned long a=0; unsigned long b=0; scanf("%lu %lu", &a, &b); printf("%lu\n",(a-b)); printf("%lu\n", (a-b)^1); return 0; }  asked 13 May '14, 13:56 1★cdamo57 5●4 accept rate: 0% 4★kunal361 6.0k●13●32●72 remove printf("%lu\n",(a-b)^1); because we can not write ^ (13 May '14, 22:59)

 1 You should not output the first line i.e. remove printf("%lu\n",(a-b)) . answered 13 May '14, 14:22 4★the65bit 1.1k●10●13●28 accept rate: 13%
 1 When a-b = 1 your answer will be zero , but it has leading zeroes . So it is giving WA . Here is your corrected code . # include < stdio.h> int main() { unsigned long a=0; unsigned long b=0; unsigned long ans=0; scanf("%lu %lu", &a, &b); ans=(a-b)^1; if (ans==0) ans=2; printf("%lu\n",ans); return 0; }  answered 13 May '14, 23:30 4★the65bit 1.1k●10●13●28 accept rate: 13% 4★kunal361 6.0k●13●32●72 Thanks. I forgot that fact. Now ok. Once again thank you. (15 May '14, 13:00) cdamo571★
 0 #include int main() { unsigned long a=0; unsigned long b=0; scanf("%lu %lu", &a, &b); printf("%lu\n", (a-b)^1); return 0; }  Again wrong... What can i do ? My way of implementation is correct ? answered 13 May '14, 21:56 1★cdamo57 5●4 accept rate: 0% 4★kunal361 6.0k●13●32●72
 toggle preview community wiki:
Preview

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported
• mathemetical formulas in Latex between \$ symbol

Question tags:

×538
×7
×6

question asked: 13 May '14, 13:56

question was seen: 701 times

last updated: 15 May '14, 15:10