• SGU 456 Annuity Payment Scheme


    D - Annuity Payment Scheme
    Time Limit:500MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u

    Description



    At the peak of the Global Economic Crisis BerBank offered an unprecedented credit program. The offering was so attractive that Vitaly decided to try it. He took a loan of s burles for m months with the interest rate of p percent. 

    Vitaly has to follow the scheme of annuity payments, meaning that he should make fixed monthly payments — x burles per month. Obviously, at the end of the period he will pay m · x burles to the bank in total. 

    Each of the monthly payments is divided by BerBank into two parts as follows:
    • The first part ai is used to pay off the percent p of the current debt. It's clear that ai=s' · p / 100 where s'=s for the first month and equals to the remaining debt for each of the subsequent months.
    • The second part bi is used to pay off the current debt. The sum of all bi over the payment period is equal to s, meaning that the borrower needs to pay off the debt completely by decreasing it from s to 0 in m months.
    BerBank uses calculations with floating-point numbers, and the value of x is uniquely determined by sm and p

    For example, if s=100, m=2, p=50 then x=90. For the first month a1 = s' · p / 100 = s · p / 100 = 50 and b1 = 90 - 50 = 40. For the second month a2 = (100-40) · 50 / 100 = 30, so b2 = 90 - 30 = 60 and the debt is paid off completely. 

    Your task is to help Vitaly and write a program that computes x given the values of sm and p.

    Input

    The single line of the input contains three integers sm and p (1 ≤ s ≤ 10 6, 1 ≤ m ≤ 120, 0 ≤ p ≤ 100).

    Output

    Output the single value of monthly payment x in burles. An absolute error of up to 10 -5 is allowed.

    Sample Input

    sample input
    sample output
    100 2 50
    
    90.00000
    

    水题,推个公式出来,注意精度...一遍A

     1 /*************************************************************************
     2     > File Name: code/2015summer/#5/D.cpp
     3     > Author: 111qqz
     4     > Email: rkz2013@126.com 
     5     > Created Time: 2015年07月30日 星期四 13时17分26秒
     6  ************************************************************************/
     7 
     8 #include<iostream>
     9 #include<iomanip>
    10 #include<cstdio>
    11 #include<algorithm>
    12 #include<cmath>
    13 #include<cstring>
    14 #include<string>
    15 #include<map>
    16 #include<set>
    17 #include<queue>
    18 #include<vector>
    19 #include<stack>
    20 #define y0 abc111qqz
    21 #define y1 hust111qqz
    22 #define yn hez111qqz
    23 #define j1 cute111qqz
    24 #define tm crazy111qqz
    25 #define lr dying111qqz
    26 using namespace std;
    27 #define REP(i, n) for (int i=0;i<int(n);++i)  
    28 typedef long long LL;
    29 typedef unsigned long long ULL;
    30 const int inf = 0x7fffffff;
    31 int s,m,p;
    32 double ans;
    33 
    34 double cal(double x,int n)
    35 {
    36     double res = 1.0;
    37     for ( int i = 1 ; i <= n ; i++ )
    38     {
    39     res = res * x;
    40     }
    41   //  cout<<"res:"<<res<<endl;
    42     return res;
    43 }
    44 int main()
    45 {
    46     cin>>s>>m>>p;
    47     double sum = 0;
    48     double per = p*1.0/100+1;
    49     for ( int i = 1 ; i <= m;  i++ )
    50     {
    51     sum=sum+1.0/cal(per,i);
    52 //    cout<<"sum:"<<sum<<endl;
    53     }
    54  //   cout<<sum<<endl;
    55     cout<<fixed<<setprecision(5)<<s*1.0/sum<<endl;
    56   
    57     return 0;
    58 }
  • 相关阅读:
    校赛writeup
    memory-300——Jarvis OJ
    校赛_warmup_pwn
    sctf
    iscc-pwn1
    level3-64——Jarvis OJ
    JarvisOJ——level2
    JarvisOJ——guestbook
    Javris oj——level0
    linux 服务器 tomcat环境部署出错 重启
  • 原文地址:https://www.cnblogs.com/111qqz/p/4690432.html
Copyright © 2020-2023  润新知