poj2390(水题)
2013-05-30 10:51
531 查看
http://poj.org/problem?id=2390
Bank Interest
Description
Farmer John made a
profit last year! He would like to invest it well but wonders how
much money he will make. He knows the interest rate R (an integer
between 0 and 20) that is compounded annually at his bank. He has
an integer amount of money M in the range 100..1,000,000. He knows
how many years Y (range: 0..400) he intends to invest the money in
the bank. Help him learn how much money he will have in the future
by compounding the interest for each year he saves. Print an
integer answer without rounding. Answers for the test data are
guaranteed to fit into a signed 32 bit integer.
Input
* Line 1: Three
space-separated integers: R, M, and Y
Output
* Line 1: A single
integer that is the number of dollars FJ will have after Y
years.
Sample Input
Sample Output
Hint
INPUT DETAILS:
5% annual interest, 5000 money, 4 years
OUTPUT DETAILS:
Year 1: 1.05 * 5000 = 5250
Year 2: 1.05 * 5250 = 5512.5
Year 3: 1.05 * 5512.50 = 5788.125
Year 4: 1.05 * 5788.125 = 6077.53125
The integer part of 6077.53125 is 6077.
Source
USACO 2004 November
Source Code
Bank Interest
Time Limit: 1000MS | Memory Limit: 65536K | |
Total Submissions: 12459 | Accepted: 7415 |
Farmer John made a
profit last year! He would like to invest it well but wonders how
much money he will make. He knows the interest rate R (an integer
between 0 and 20) that is compounded annually at his bank. He has
an integer amount of money M in the range 100..1,000,000. He knows
how many years Y (range: 0..400) he intends to invest the money in
the bank. Help him learn how much money he will have in the future
by compounding the interest for each year he saves. Print an
integer answer without rounding. Answers for the test data are
guaranteed to fit into a signed 32 bit integer.
Input
* Line 1: Three
space-separated integers: R, M, and Y
Output
* Line 1: A single
integer that is the number of dollars FJ will have after Y
years.
Sample Input
5 5000 4
Sample Output
6077
Hint
INPUT DETAILS:
5% annual interest, 5000 money, 4 years
OUTPUT DETAILS:
Year 1: 1.05 * 5000 = 5250
Year 2: 1.05 * 5250 = 5512.5
Year 3: 1.05 * 5512.50 = 5788.125
Year 4: 1.05 * 5788.125 = 6077.53125
The integer part of 6077.53125 is 6077.
Source
USACO 2004 November
Source Code
#include<stdio.h> int main() { double sum; int R,M,Y; int i; while(scanf("%d %d %d",&R,&M,&Y)!=EOF) { double s=1.0; sum=1.0; for(i=1;i<=Y;i++) { sum*=(double)(1.0+(double)R/100.0); } s*=sum*M; printf("%d\n",(int)s); } return 0; }
相关文章推荐
- POJ 2390 Bank Interest(我的水题之路——double和floa计算差别)
- POJ2390 Bank Interest【水题】
- poj 2390 水题 Bank Interest
- POJ,北大OJ2027,No Brainers难得的水题。。
- POJ1005-I Think I Need a Houseboat(水题)
- poj_2017 水题
- POJ 1083 Moving Tables(水题)
- poj_3224 不解题意注定不解风情,此水题害苦了我
- POJ 3264 Balanced Lineup(线段树水题)
- poj 2390 Bank Interest(计算本利和)
- 基本算法dijkstra的POJ水题推荐
- poj入门水题整理7
- poj 2390
- POJ1207 水题
- poj-1265-area几何水题+pick定理模板
- poj 1250 水题
- poj 1488 TEX Quotes(字符串水题)
- poj 1148 TEX Quotes 【水题(字符串替换)】【周赛】
- POJ 1318 Word Amalgamation(我的水题之路——乱序字母匹配)
- POJ 1517 u Calculate e(我的水题之路——特殊格式,打表)