NUC1373 Bank Interest【水题】
生活随笔
收集整理的這篇文章主要介紹了
NUC1373 Bank Interest【水题】
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
Bank Interest
時間限制: 1000ms 內存限制: 65535KB
通過次數: 1總提交次數: 1
問題描述 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. 輸入描述 * Line 1: Three space-separated integers: R, M, and Y 輸出描述 * Line 1: A single integer that is the number of dollars FJ will have after Y years. 樣例輸入 5 5000 4 樣例輸出 6077 來源 USACO 2004 November Gold 提示 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.
問題分析:(略)
這個問題和《POJ2390 Bank Interest【水題】》是同一個問題,代碼直接用就AC了。
程序說明:參見參考鏈接。
參考鏈接:POJ2390 Bank Interest【水題】
題記:程序做多了,不定哪天遇見似曾相識的。AC的C++程序如下:
/* POJ2390 Bank Interest */#include <iostream> #include <cmath>using namespace std;int main() {int r, m, y;cin >> r >> m >> y;cout << (int)(m * pow(1 + r / 100.0, y)) << endl;return 0; }轉載于:https://www.cnblogs.com/tigerisland/p/7563669.html
總結
以上是生活随笔為你收集整理的NUC1373 Bank Interest【水题】的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: RabbitMQ安装与初始配置
- 下一篇: Ubuntu增加(swap)交换分区