SGU 456 Annuity Payment Scheme

D - Annuity Payment Scheme

Time Limit:500MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u

Submit Status Practice SGU 456

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: [email protected]
 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 }
时间: 2024-10-10 08:28:00

SGU 456 Annuity Payment Scheme的相关文章

暑假训练-个人赛第五场

    ID Origin Title   0 / 23 Problem A SGU 453 Meetings     Problem B SGU 454 Kakuro 10 / 58 Problem C SGU 455 Sequence analysis 14 / 52 Problem D SGU 456 Annuity Payment Scheme     Problem E SGU 457 Snow in Berland   0 / 1 Problem F SGU 458 The Mono

hdu 1350 Taxi Cab Scheme(二分匹配)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1350 Taxi Cab Scheme Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 943    Accepted Submission(s): 456 Problem Description Running a taxi stati

sgu 463 - Walking around Berhattan

K - Walking around Berhattan Time Limit:250MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit Status Practice SGU 463 Description As you probably know, Berhattan is a district of Berland's largest city and it consists of equal squar

Xcode6.4注册URL Scheme步骤详解

URL Scheme的作用 我们都知道苹果手机中的APP都有一个沙盒,APP就是一个信息孤岛,相互是不可以进行通信的.但是iOS的APP可以注册自己的URL Scheme,URL Scheme是为方便app之间互相调用而设计的.我们可以通过系统的OpenURL来打开该app,并可以传递一些参数. 例如:你在Safari里输入www.alipay.com,就可以直接打开你的支付宝app,前提是你的手机装了支付宝.如果你没有装支付宝,应该显示的是支付宝下载界面,点击会跳到AppStore的支付宝下载

(已解决)#warning:尚未配置[微信]URL Scheme:wx4868b35061f87884, 无法使用进行授权。

#warning:尚未配置[微信]URL Scheme:wx4868b35061f87884, 无法使用进行授权. (说白了就是注册白名单) " -canOpenURL: failed for URL: "weixin://app/wx4868b35061f87885/" - error: "This app is not allowed to query for scheme weixin"  " 此error源自iOS9 URL Scheme

【SGU 390】Tickets (数位DP)

Tickets Description Conductor is quite a boring profession, as all you have to do is just to sell tickets to the passengers. So no wonder that once upon a time in a faraway galaxy one conductor decided to diversify this occupation. Now this conductor

ACM: SGU 101 Domino- 欧拉回路-并查集

sgu 101 - Domino Time Limit:250MS     Memory Limit:4096KB     64bit IO Format:%I64d & %I64u Description Dominoes – game played with small, rectangular blocks of wood or other material, each identified by a number of dots, or pips, on its face. The bl

Vim Color Scheme

Molokai Color Scheme for Vim I prefer molokai's dark grey background. Installation with Pathogen cd ~/.vim/bundle && \git clone https://github.com/tomasr/molokai.git Now Molokai is installed. Add the following to your vimrc. " Set color schem

全民Scheme(0):lat的定义

接下来我会写一写Scheme的学习笔记.嗯,Scheme是属于小众的语言,但合适用来教学的. 什么是lat,就是遍历list里的每个S-expression,如果发现其中某个不是atom的,则返回false,否则返回true. (define atom? (lambda (x) (and (not (pair? x)) (not (null? x))))) (define lat? (lambda (l) (cond ((null? l) #t) ((atom? (car l)) (lat? (