Thursday, October 4, 2007

ACM/ICPC Indonesia National Contest 2007 - Qualification

Avoiding Financial Nightmare

GCC/Visual C++: avoid.cpp Java: avoid.java
Time Limit: 1s


Nowadays, getting a loan from a bank or financial company has become very popular, either it?s for commercial or personal purposes. If you are a well-managed on your expenses, having a loan from a bank or using credit cards for your expenses could be a good help, otherwise it could be your worst financial nightmare. By considering the risks of paying bills, our professor has decided to get a loan to buy a new house on a pleasant city in Indonesia.

Our professor has considered 3 main variables that will affect his monthly bills:
  • Principal, the remaining amount of the loan
  • Period, the number of months to pay off the loan
  • Rate, the monthly interest rate

    To help their customer, bank or financial company normally offers a fixed amount payment system. Every month the customer should pay a fixed amount of money which consists of two kinds of payment:
    1. Interest Payment.
      Interest Payment = Rate x Remaining Principal.
      The amount of interest payment should be rounded up to the higher nearest integer.

    2. Principal Payment.
      Principal Payment = Total Payment - Interest Payment.
      The previous Principal is to be subtracted with the current Principal Payment to get the current Principal.
    The total monthly payment should be calculated in some way so that the total monthly payment to be paid spread evenly each month, and at the end of the period the remaining Principal is zero or a negative amount nearest to zero (if it?s not possible to reach zero).

    For example, let the professor get a loan in the amount of $42,000 with 5% interest rate per month that should be paid in 5 months.
    Term Payment Principal
    Total Interest Payment Principal Payment
    - - - - $42,000
    1 $9,701 $2,100 $7,601 $34,399
    2 $9,701 $1,720 $7,981 $26,418
    3 $9,701 $1,321 $8,380 $18,038
    4 $9,701 $902 $8,799 $9,239
    5 $9,701 $462 $9,239 $0

    1st term: He should pay $9,701 ($2,100 for interest payment, and $7,601 for principal payment)
    Interest Payment : 5% x $42,000 = $2,100
    Principal Payment : $9,701 - $2,100 = $7,601
    Current Principal : $42,000 - $7,601 = $34,399

    2nd term: He pays $9,701 ($1,702 for interest payment, and $7,981 for principal payment)
    Interest Payment : 5% x $34,399 = $1,720
    Principal Payment : $9,701 - $1,720 = $6,902
    Current Principal : $34,399 - $6,902 = $26,418, and so on.

    Unfortunately, the professor is terrible with financial stuffs. We don?t want him to end up broke, do we? So, let us help him with the calculation on how much money he should spend to pay his monthly bills on the loan. In that way, the professor will be able to buy his new house and who knows that someday we might be invited to visit his house in return to our help.


    Input Specification

    The input contains multiple cases. Each case consists of three integers respectively, N (1<=N<=10,000,000) the initial principal, M (1<=M<=100) the period, and R (0<=R<=100) the percent rate.

    Output Specification

    For each case, you should output in a single line the total monthly payment should be made to satisfy the condition.


    Sample Input

    42000 5 5
    100000 10 10

    Sample Output

    9701
    16275
    Click di sini untuk melihat jawaban
  • 11 comments:

    Felix Halim said...

    Hallo, solusi problem ini adalah menggunakan binary search:

    http://felix-halim.net/story/inc07/penyisihan-writeup-b-avoid.php

    Kamu bisa mengecek jawaban kamu benar atau salah mencocokkan jawaban kamu dengan jawaban juri. Input/output/solusi juri bisa di download disini:

    http://felix-halim.net/story/inc07/penyisihan-data/penyisihan-data.zip

    Kalau kamu tertarik dengan soal2 yang lain di babak final, silahkan lihat disini:

    http://felix-halim.net/story/inc07/index.php

    Anonymous said...

    Hi !.
    You re, I guess , probably very interested to know how one can make real money .
    There is no need to invest much at first. You may start to get income with as small sum of money as 20-100 dollars.

    AimTrust is what you need
    The company incorporates an offshore structure with advanced asset management technologies in production and delivery of pipes for oil and gas.

    It is based in Panama with structures around the world.
    Do you want to become an affluent person?
    That`s your choice That`s what you really need!

    I`m happy and lucky, I started to take up real money with the help of this company,
    and I invite you to do the same. If it gets down to select a proper companion who uses your funds in a right way - that`s AimTrust!.
    I earn US$2,000 per day, and what I started with was a funny sum of 500 bucks!
    It`s easy to start , just click this link http://jywameso.freecities.com/ucydane.html
    and lucky you`re! Let`s take this option together to get rid of nastiness of the life

    Anonymous said...

    Hello !.
    You re, I guess , probably very interested to know how one can collect a huge starting capital .
    There is no need to invest much at first. You may start earning with as small sum of money as 20-100 dollars.

    AimTrust is what you thought of all the time
    The firm incorporates an offshore structure with advanced asset management technologies in production and delivery of pipes for oil and gas.

    Its head office is in Panama with affiliates everywhere: In USA, Canada, Cyprus.
    Do you want to become an affluent person?
    That`s your choice That`s what you wish in the long run!

    I feel good, I started to take up income with the help of this company,
    and I invite you to do the same. It`s all about how to select a correct companion utilizes your money in a right way - that`s the AimTrust!.
    I make 2G daily, and my first deposit was 1 grand only!
    It`s easy to start , just click this link http://javilybago.uvoweb.net/ymeqiky.html
    and go! Let`s take our chance together to feel the smell of real money

    Anonymous said...

    Your blog keeps getting better and better! Your older articles are not as good as newer ones you have a lot more creativity and originality now keep it up!

    Anonymous said...

    Bookmarked this. Thanksgiving owing to you for sharing. Positively benefit my time.

    Anonymous said...

    Good day, sun shines!
    There have been times of hardship when I didn't know about opportunities of getting high yields on investments. I was a dump and downright pessimistic person.
    I have never thought that there weren't any need in big initial investment.
    Now, I feel good, I started to get real money.
    It gets down to select a proper partner who utilizes your funds in a right way - that is incorporate it in real business, and shares the profit with me.

    You can get interested, if there are such firms? I'm obliged to answer the truth, YES, there are. Please be informed of one of them:
    [url=http://theblogmoney.com] Online investment blog[/url]

    Anonymous said...

    Hi!
    You may probably be very curious to know how one can make real money on investments.
    There is no initial capital needed.
    You may begin earning with a money that usually goes
    on daily food, that's 20-100 dollars.
    I have been participating in one company's work for several years,
    and I'm ready to share my secrets at my blog.

    Please visit my pages and send me private message to get the info.

    P.S. I earn 1000-2000 per daily now.

    [url=http://theinvestblog.com] Online investment blog[/url]

    Anonymous said...

    This is a great article as they all are. I bring into the world been wondering wide this as some measure now. Its great to get this info. You are fete and balanced.

    Anonymous said...

    Good day, sun shines!
    There have been times of troubles when I felt unhappy missing knowledge about opportunities of getting high yields on investments. I was a dump and downright pessimistic person.
    I have never imagined that there weren't any need in big starting capital.
    Nowadays, I'm happy and lucky , I started take up real income.
    It gets down to choose a correct companion who utilizes your funds in a right way - that is incorporate it in real business, and shares the profit with me.

    You can ask, if there are such firms? I have to answer the truth, YES, there are. Please get to know about one of them:
    http://theinvestblog.com [url=http://theinvestblog.com]Online Investment Blog[/url]

    Anonymous said...

    Glad to materialize here. Good day or night everybody!

    We are not acquainted yet? It’s easy to fix,
    my name is Peter.
    Generally I’m a venturesome analyst. all my life I’m carried away by online-casino and poker.
    Not long time ago I started my own blog, where I describe my virtual adventures.
    Probably, it will be interesting for you to read my notes.
    Please visit my web site. http://allbestcasino.com I’ll be glad would you find time to leave your comments.

    Anonymous said...

    Glad to greet you, ladies and gentlemen!

    For sure you didn’t here about me yet,
    friends call me Nikolas.
    Generally I’m a venturesome gambler. recently I take a great interest in online-casino and poker.
    Not long time ago I started my own blog, where I describe my virtual adventures.
    Probably, it will be interesting for you to read my notes.
    Please visit my web site. http://allbestcasino.com I’ll be glad would you find time to leave your opinion.