You are not logged in. Please login at www.codechef.com to post your questions!

×

ADDBIT - Editorial

PROBLEM LINK:

Practice

Contest

Author: Akshay Venkataramani

Tester: Timothy Jeyadoss

DIFFICULTY:

Cakewalk

PREREQUISITES:

Strings

EXPLANATION:

Simply traverse the string from left to right, and when you find a 0, break from the loop. Until then, keep adding to the answer.

This is the basic idea behind binary addition of 1 to any binary number(ofcourse, with the slight modification that if all bits are 1, append a extra 1 at the beginning).

This problem can be solved easily using "string" datatype that is available in C++, Java, Python etc. It is a little tedious to solve this problem in C, but simple nevertheless when you make note of the constraints properly.

TESTER'S SOLUTION:

Tester's solution can be found here.

This question is marked "community wiki".

asked 21 Jan '18, 17:20

akshayvenkat97's gravatar image

5★akshayvenkat97
1.1k416
accept rate: 0%

edited 05 Feb '18, 13:55

admin's gravatar image

0★admin ♦♦
19.8k350498541

toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • 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:

×15,639
×1,646
×349
×29
×3

question asked: 21 Jan '18, 17:20

question was seen: 181 times

last updated: 05 Feb '18, 13:55