Thread: help needed

  1. #1
    Registered User
    Join Date
    Jan 2009
    Posts
    71

    help needed

    can any 1 plz help me in solving this problem
    http://www.spoj.pl/problems/MZVRK/

    here's what i have

    Code:
    => the zvrks of any odd number will be =1 . 
    => all the numbers (when the process is done) will have exactly one '1' & remaining 
    zeros hence when converted back to decimal each number will be in the form 2^k . 
    => these numbers have certain pattern . 
    
    ex: if sum of all zvrks from 2^k <=> 2^k+1 is Z , then sum of all zvrks of 2^k+1 <=> 
    2^k+1 will be 2*Z+(2^k+1 - 2^k) . [:P] 
    
    but nt able to proceed after this
    I'd be grateful if any 1 can help !

    thank u very much

  2. #2
    Registered User
    Join Date
    Nov 2006
    Location
    japan
    Posts
    126

    Talking Hey ... Is this homework?

    I hope this is not homework...
    but I will give some hints anyway.

    A way of doing this could be converting your number to binary and doing all the stuff as normal people.

    But, realize that the whirligig of a number is always a number of the form 1000 ... 000 and that number could be represented as pow(2,n) where n is the number of digits of your whirligig number.

    You could extract the right most n digits and then compare it to pow(2,n) if is equal then you have your whirligig number , if not you increment n by one and compare again.

    For extracting the left most n binary digits of a integer study about exclusive disjunction (logic or, logic and etc)

    I hope you can do it with this algorithm...



    Quote Originally Posted by jack_carver View Post
    can any 1 plz help me in solving this problem
    http://www.spoj.pl/problems/MZVRK/

    here's what i have

    Code:
    => the zvrks of any odd number will be =1 . 
    => all the numbers (when the process is done) will have exactly one '1' & remaining 
    zeros hence when converted back to decimal each number will be in the form 2^k . 
    => these numbers have certain pattern . 
    
    ex: if sum of all zvrks from 2^k <=> 2^k+1 is Z , then sum of all zvrks of 2^k+1 <=> 
    2^k+1 will be 2*Z+(2^k+1 - 2^k) . [:P] 
    
    but nt able to proceed after this
    I'd be grateful if any 1 can help !

    thank u very much
    Mac OS 10.6 Snow Leopard : Darwin

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. free needed or not?
    By quantt in forum Linux Programming
    Replies: 3
    Last Post: 06-25-2009, 09:32 AM
  2. C Programmers needed for Direct Hire positions
    By canefan in forum Projects and Job Recruitment
    Replies: 0
    Last Post: 09-24-2008, 11:55 AM
  3. lock needed in this scenario?
    By George2 in forum C# Programming
    Replies: 1
    Last Post: 05-25-2008, 07:22 AM
  4. C++ help needed
    By Enkindu in forum Projects and Job Recruitment
    Replies: 3
    Last Post: 08-31-2004, 11:24 PM
  5. semi-colon - where is it needed
    By kes103 in forum C++ Programming
    Replies: 8
    Last Post: 09-12-2003, 05:24 PM