ABCLOG - Time to get a job

no tags 

ABC Pvt. Ltd., needs to recruit some candidates and they want the test to be somewhat new, rather than the conventional way of asking questions in all areas. They have a logic, which converts one integer to another. Your task is to find the logic behind it and then solve the questions for certain inputs.

The question given by them is as follows:

The following are the output provided for the inputs given to one of our newly bought machines. You need to find the output that will be generated for the given inputs. Some sample input and output are:

   4 -> 1, 23 -> 29, 7 -> 7  16 -> 1

 

Your task is to find the machine's output for some inputs

Input

Input contains several integers, each in a single line.

Input ends with a -1

All inputs <= 10^16

Output

Output one integer for every input, as said above.

Example

Input:
4
7
23
-1

 Output: 1
7
29

hide comments
Lakshay Singhal: 2014-01-08 15:12:19

AC in first attempt... my 150th...nyc and simple que.
d logic lies in basics....

Last edit: 2014-01-08 15:12:47
SanchitK: 2014-01-03 08:32:53

AC at first attempt! :D

ritz: 2014-01-03 05:12:08

wow.. nice problem... :) (Y)

pushkar nagar: 2014-01-01 20:07:30

acc with fast i/o.....

saurabh jain: 2014-01-01 17:15:47

please admin check this my code 10780992 got compilation error with with c++ 4.3.2 but successfully aced with 4.0.0.-8 why
??

..........: 2013-12-31 17:45:39

After 7 WAs finally accepted!50th prob......

Martijn Muijsers: 2013-12-31 01:04:06

Easy logic, but I don't like this type of description I guess.

Last edit: 2013-12-31 01:18:20
pika_pika: 2013-12-30 19:52:13

big hint! thanks @pǝddıןɟ

[Lakshman]: 2013-12-30 16:20:51

@ Saransh Sharma all numbers are positive.

Saransh Sharma: 2013-12-30 15:47:09

does input contains negative integers also?


Added by:Aswin Murugesh
Date:2013-12-21
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64
Resource:Own Problem