Infinite Cash

시간 제한1초메모리 제한1024 MB

요약
매일 남은 돈의 절반을 올림해서 쓰고 d일마다 급여를 받을 때, 돈이 떨어지거나 영원히 반복되는 시점을 구한다.
난이도

보통10점 중 5점

유형
시뮬레이션, 수학, 구현, 비트 연산
정답자
아직 제출이 없습니다

문제

Svalur Handsome has finally graduated with a degree in computer science, and it couldn't have happened sooner. He has some rather unwise spending habits which he hopes will be more sustainable now that he can get a high paying job as a programmer. He has applied to a few places, and now has a contract in his hands that he could sign and start working almost immediately. But before he takes the offer he wants to figure out how long it could support his spending habits.

At the start of every day Svalur spends half of his remaining money, rounded up. The new job would pay ss ISK at the end of every dd-th day, starting with the dd-th day. He currently has mm ISK to spend as well.

입력

The input has three lines, each containing the positive integers s,d,ms, d, m respectively. They satisfy 1≤s,d,m≤210001 \leq s, d, m \leq 2^{1000}. As these payment details are for a computer science job the numbers are all given in binary, naturally.

출력

Print the number of the day that Svalur wants to spend money, but has none. This should naturally also be printed in binary. If he can support his spending habits indefinitely instead print Infinite money!.

예제3

  1. 예제 1

    입력
    101110101
    1010
    10001110101010101
    
    예상 출력
    10011
    
  2. 예제 2

    입력
    101110101
    1000
    100011101
    
    예상 출력
    Infinite money!
    
  3. 예제 3

    입력
    101110101
    1010
    100011101
    
    예상 출력
    1001