PupuTime
limit:2000/1000 MS (java/others) Memory limit:32768/32768 K (java/others)
Total submission (s): 1133 Accepted Submission (s): 445
Problem Descriptionthere is an island called pilipala.in the island there are a wild animal living in it, and can call them pupu. Pupu is a kind of special animal, infant PuPus play under the sunshine, and adult PuPus hunt near the seaside. They fell happy every day.
But there was a question, when does an infant pupu become an adult pupu?
Aha, we already said, Pupu is a special animal. There is several skins wraping Pupu's body, and Pupu ' s skins is special also, they has both states, clarity and opacity. The opacity skin would become clarity skin if it absorbs sunlight a whole day, and sunshine can pass through the clarity s Kin and shine the inside skin; The clarity skin would become opacity, if it absorbs sunlight a whole day, and opacity skin would keep sunshine out.
When an infant Pupu is born, all of their skins were opacity, and since the day, all of a pupu ' s skins have been changed From opacity to clarity, Pupu are an adult pupu.
For example, a pupu who had only 3 skins would become an adult pupu after it born 5 days (what a pity! The little guy would sustain the pressure from life (5 days)
Now give you the number of skins belongs to a new-laid Pupu, tell me what many days later it would become an adult pupu?
Inputthere is many testcase, each testcase only contains one integer N, the number of skins, process until N equals 0
Outputmaybe an infant pupu and skins need a million days to become an adult pupu, so you should output the result mod N
Sample Input
230
Sample Output
12
Source2009 multi-university Training Contest 11-host by Hrbeu
Test instructions: Pupu has n layers of skin, each layer of skin has 2 states: transparent and opaque, each layer of skin if it can be irradiated by the sun, then the sun will be a day after the change of state.
Pupu at birth, all the skin is opaque, until each layer of skin has become transparent state, Pupu also grow up.
Ask the Pupu with n layers of skin to grow up a few days later.
Idea: You can launch the formula ans = (2^ (n-1) + 1)%n, and then follow the quick power modulo calculation (no, LL and WA again!)
AC Code:
Hdu-3003-pupu (Quick power modulo!) )