P2942 [USACO09MAR] Moon Mooing G

题目描述

A full moon casts some sort of spell on the cows and, like their cousins the wolves and coyotes, they bay at the moon -- mooing instead of howling, of course. Each 'moo' lasts a certain amount of time. A short 'moo' might last time 1; a longer one might last time 24 or even 1,000,000,000 or longer (cows can really moo when they want to). No 'moo' will last more than or equal to 2^63. It should come as no surprise that the cows have a pattern to their moos. Bessie will choose an integer c (1

输入格式

\* Line 1: Two space-separated integers: c and N \* Line 2: Three space-separated integers: a1, b1, and d1 \* Line 3: Three space-separated integers: a2, b2, and d2

输出格式

\* Line 1: A single line which contains a single integer which is the length of the Nth moo