CSP 202212-1 现值计算

黎 浩然/ 18 8 月, 2023/ 算法/ALGORITHMS/ 0 comments

C++:100/100

#include "bits/stdc++.h"
using namespace std;

int main() {
    double n, i, money, total = 0;
    cin >> n >> i;
    for (int j = 0; j <= n; ++j) {
        cin >> money;
        total += money * pow(1 + i, -j);
    }
    cout << total << endl;
}
Share this Post

Leave a Comment

您的邮箱地址不会被公开。 必填项已用 * 标注

*
*