CodeChef is a non-commercial competitive programming community
Login
Username (New User? Signup) Password (Forgot Password?)
Signup
Login or
Signup with
Connect
Note
  • Publicize your achievements on your Facebook Wall.
  • Challenge your friends or ask them for help.

Site Navigation

  • PRACTICE
    • Easy
    • Medium
    • Hard
    • Challenge
    • Peer
  • COMPETE
    • All Contests
    • June Long 2012
    • May Cook-Off
    • May Long 2012
  • DISCUSS
    • Wiki
    • Forums
    • Blog
    • Facebook
    • Twitter
  • COMMUNITY
    • CodeChef Meetups
    • Campus Chapters
    • Host your Contest
    • User Groups
    • CodeChef TechTalks
    • All Educational Initiatives
    • Event Calendar
  • HELP
    • Frequently Asked Questions
    • FAQ for problem setters
    • Problem Setting
    • Tutorials
    • Long Contest Ranks
    • Short Contest Ranks
  • ABOUT
    • About CodeChef
    • Team CodeChef
    • Press Room
    • CodeChef Financials
    • CodeChef Sponsorships
    • CEO's Corner
    • Contact Us
    • About Directi
Home » Compete » CE 2010 » Octal Looks

Octal Looks

Problem code: CE05

  • All Submissions

Write a program to find the number of set bits in the binary representation of a decimal number and print its ouptut in the proper coded format as given by the test cases below.

Input

You need to enter a natural number

Output

Output should be the number of set bits in the binary notation of the number

Example

Input:
5
34
654
64
245

Output:
10
24
4
30
20


Author: cerebration
Date Added: 23-03-2010
Time Limit: 1 sec
Source Limit: 50000 Bytes
Languages: BF, CLOJ, CPP 4.3.2, F#, GO, ICK, JS, PERL6, PRLG, PYTH 3.1.2, TEXT, WSPC


  • Submit

Comments

  • Login or Register to post a comment.

Can you explain what are set

mehrotra.akash @ 26 Mar 2010 10:29 PM

Can you explain what are set bits??

is the sample test data

chang @ 27 Mar 2010 01:19 PM

is the sample test data correct ? plz check it.

yah i think the sample output

tmvipinster @ 28 Mar 2010 01:33 AM

yah i think the sample output is wrong.just stick to problem statement i think its easy to sort it out :D

u mean v just need to print

chang @ 28 Mar 2010 02:21 AM

u mean v just need to print the no of set bits in the decimal representation ? even dat doesnt works..

hey tmdada...plz reply.

chang @ 28 Mar 2010 02:38 AM

hey tmdada...plz reply.

Can any one of u please

SITZ @ 28 Mar 2010 09:44 AM

Can any one of u please explain the problem clearly... Really not getting any clue about it ....

please help . . .

The sample outputs are

Manoharprabhu @ 28 Mar 2010 03:06 PM

The sample outputs are completely wrong :P

just do what the statement tells you to do  :D

can someone explain how for

aarpit @ 28 Mar 2010 03:36 PM

can someone explain how for sample input 5 output is 10,,

and if its wrong what is the correct answer

Manoharprabhu hey is correct

aarpit @ 28 Mar 2010 06:49 PM

Manoharprabhu hey is correct answeer for the test cases can you please reply

@Manohar prabhu whats the

chang @ 28 Mar 2010 07:19 PM

@Manohar prabhu

whats the proper coded format here ? Is it just the no of set bits in decimal system ?

admins, plz correct the

chang @ 28 Mar 2010 07:21 PM

admins, plz correct the sample test data..

SITZ plz can u tell wheter

heeropunjab @ 28 Mar 2010 09:53 PM

SITZ plz can u tell wheter the octal program test case is correct or not

those who have solved the

aarpit @ 29 Mar 2010 12:01 AM

those who have solved the question can anyone respond ???

give answeers to the input test cases

Hi There is no problem in the

cerebration @ 29 Mar 2010 10:50 AM

Hi

There is no problem in the question,please look at the question name and the statement  carefully,especially the last part of the problem statements.

Regards

Rohan Garg

@ rohan ..can u plz explain

mcsharma1990 @ 29 Mar 2010 11:42 AM

@ rohan ..can u plz explain the sample test cases?

somebody please clear out any

jitendra_theta @ 29 Mar 2010 05:50 PM

somebody please clear out any of the test case please????

Ok ive corrected

cerebration @ 29 Mar 2010 06:32 PM

Ok ive corrected everything,now you should know there is one more step before encoding the output.Also those who have already solved it please do not give out the answers as it hits your own chances of winning,we have a limited number of problems

Thanks

Rohan Garg

Hi the new problem reads as

cerebration @ 29 Mar 2010 06:37 PM

Hi the new problem reads as follows

Write a program to find the number of set bits in the binary representation of a decimal number and print its ouptut in the proper coded format as given by the test cases below.

Input

The first line consists of number of test cases and next lines consist of the number to be coded.

Output

Output should be the number of set bits in the binary notation of the number

Example

Input:
5
34
654
64
245
23 
Output:
10
24
4
30
10


@ALL Please take T test cases

Manoharprabhu @ 29 Mar 2010 06:38 PM

@ALL

Please take T test cases as input first.

Then take T number of inputs and output the number of set bits in its binary representation.

Input: 5346546424523 Output:

Manoharprabhu @ 29 Mar 2010 06:40 PM

Input:
5
34
654
64
245
23
Output:
2
5
1
6
4

------------------------

This is the correct output

Ok in the last post please

cerebration @ 29 Mar 2010 06:52 PM

Ok in the last post please replace the last 10 in the output with 20

hey rohan plz check out

code.freak @ 29 Mar 2010 07:13 PM

hey rohan plz check out whether the output given by u is correct.....the output of Manohar seems correct but is not accepted?????

@ankit output is correct,

aarpit @ 29 Mar 2010 07:16 PM

@ankit

output is correct, just read the comments posted above

i am submitting according to

code.freak @ 29 Mar 2010 07:18 PM

i am submitting according to the output of manohar but its not accepting???

is the number to be coded a

code.freak @ 29 Mar 2010 07:21 PM

is the number to be coded a Natural Number????

plz specify....

@Ankit Are you printing all

Manoharprabhu @ 29 Mar 2010 07:28 PM

@Ankit

Are you printing all the results in a newline?

@Manohar yes i am printing

code.freak @ 29 Mar 2010 07:29 PM

@Manohar

yes i am printing the results in new lines...

and are the test cases natural numbers only???

@ankit   hey ankit...dont go

chang @ 29 Mar 2010 07:52 PM

@ankit

 

hey ankit...dont go with manohar's o/p....dats incomplete. Rohan's new test data is correct.

:P :P ok .. do as you wish :D

Manoharprabhu @ 29 Mar 2010 08:11 PM

:P :P ok .. do as you wish :D

@Kushagra Gour By the way,

Manoharprabhu @ 29 Mar 2010 08:16 PM

@Kushagra Gour

By the way, can you explain how 34 has 10 set bits according to sample output?

@Manohar prabhu Pleas note

cerebration @ 29 Mar 2010 09:19 PM

@Manohar prabhu Pleas note that ive encoded the output,so you need to look carefully and work it out.

Please do not discuss the solutions as this will hamper your own progress.

The new sample i/p and o/p is absolutely correct

@All yes the numbers are

cerebration @ 29 Mar 2010 09:20 PM

@All yes the numbers are supposed to be natural numbers,the test cases have been designed keeping this in mind

What will be the o/p for 56?

ishan.mit @ 29 Mar 2010 10:04 PM

What will be the o/p for 56?

Anyway, my solution has been

Manoharprabhu @ 29 Mar 2010 10:42 PM
Anyway, my solution has been accepted for getting output my way....

@Rohan Garg as u r saying

muke @ 29 Mar 2010 11:08 PM

@Rohan Garg

as u r saying that

Input:
5
34
654
64
245
23 
Output:
10
24
4
30
10

r absolutely correct then

WHY MY PROGRAM IS NOT ACCEPTED THOUGH IT IS GIVING SAME O/P

 

can u please provide 1 or 2 more test case so that every one can get their doubts seeing those test cases

@mukesh the last one is

mehrotra.akash @ 29 Mar 2010 11:14 PM

@mukesh

the last one is correct

no more hints as this will be the deciding question of the competition

I meant the last O/P given by

mehrotra.akash @ 29 Mar 2010 11:19 PM

I meant the last O/P given by rohan is correct(except that it is 20 for 23 not 10 as mentioned above)

I visited Mohan Prabhu's

linuxfreak @ 29 Mar 2010 11:51 PM

I visited Mohan Prabhu's profile.. and there... CE05 is not shown as solved by him.... :-( ... a bit of confusion in the ranking.... might be some technical issues during him submission time... CE05 works with Rohan Garg's description.. and.. Rohan is the coordinator of this event i think.. so definetly he is correct!!! @ mohan visit your profile.. and... check.. for CE05!!! there are others also with points 7 and.. their profile showing.. just 6 solved for this event!!! :-0 .. i too had to resubmit a solved problem to make it to 7... :-(

@Admin: I have solved all the

SITZ @ 30 Mar 2010 04:08 AM

@Admin: I have solved all the 7 questions and my profile verifies it too... but my score still is 6..

please recheck the ranks and correct the technicalities there, if any..

thnx...

@ Rohan Garg hey man please

muke @ 30 Mar 2010 10:03 PM

@ Rohan Garg

hey man please reply to me post

also please reply

what should b output of 56

abe kya natak laga

akashheart02 @ 31 Mar 2010 08:58 PM

abe kya natak laga rakha

suno yaar tumhe pahele batana chahiye tha ya email karna chahiye tha

this is not fair with us.

I spent my whole day for solving these problems now you are saying you haven't registred.

sending information of this much value throungh comment is not good.

please be fair in judging.

:(

:(

:(

SUCCESSFUL SUBMISSIONS FOR THIS PROBLEM:

Programming Competition Fetching successful submissions
Directi Go for Gold
CodeChef is a global programming communityCodeChef hosts online programming competitions
CodeChef is a non-commercial competitive programming community
  • About CodeChef
  • About Directi
  • CEO's Corner
  • C-Programming
  • Programming Languages
  • Contact Us
© 2009 Directi Group. All Rights Reserved. CodeChef uses SPOJ © by Sphere Research Labs
In order to report copyright violations of any kind, send in an email to copyright@codechef.com
CodeChef a product of Directi
The time now is:
CodeChef - A Platform for Aspiring Programmers

CodeChef was created as a platform to help programmers make it big in the world of computer programming. At CodeChef we work hard to revive the geek in you by hosting programming contests on a monthly basis. We also aim to have training sessions and events related to online programming for programmers around the world. Apart from providing a platform for programming competitions, CodeChef also has various tutorials and forum discussions to help those who are new to the world of computer programming.

Practice Section - A Place to hone your 'Computer Programming Skills'

Try your hand at one of our many practice problems and submit your solution in a language of your choice. Our judge accepts solutions in over 35+ programming languages. Online programming was never this much fun! Receive points, and move up through the CodeChef ranks. Use our practice section to better prepare yourself for the multiple programming competitions that take place through-out the month on CodeChef.

Compete - Monthly Programming Contests and Cook-offs

Here is where you can show off your computer programming skills. Take part in our 10 day long monthly programming contests and the shorter format Cook-off programming contests. Put yourself up for recognition and win great prizes. Prizes worth up to Rs.20,000 and $700 are up for grabs every month along with lots more CodeChef goodies.

Discuss

Are you new to computer programming? Do you need help with algorithms? Then be part of CodeChefs Forums and interact with all our programmers love helping out other programmers and share their ideas.

CodeChef Community

As part of our Educational initiative, we give institutes the opportunity to associate with CodeChef in the form of Campus Chapters. Hosting online programming competitions is not the only feature on CodeChef. Be a part of the CodeChef community through CodeChef meetups and techtalks. You can also host a programming contest for your institute on CodeChef and be a guest author on our blog.

Go For Gold

The Go for Gold Initiative was launched about a year after CodeChef was incepted, to help prepare Indian students for the ACM ICPC World Finals competition. In the run up to the ACM ICPC competition, the Go for Gold initiative uses CodeChef as a platform to train students for the ACM ICPC competition via multiple warm up contests. As an added incentive the Go for Gold initiative is also offering over Rs.8 lacs to the Indian team that beats the 29th position at the ACM ICPC world finals. Find out more about the Go for Gold and the ACM ICPC competition here.

Domain Name Registration, Web hosting, and Website Design provided by BigRock.com