跳到正文

题解

题解:P13897 [CSPro 28] 现值计算

梨花诗约 1 分钟
原文
文章信息与版本

文章信息

收录
2025年12月12日
更新
2026年5月19日
篇幅
约 1 分钟
题目
P13897

版本

  1. v1当前

照题意模拟即可。

C++
#include <bits/stdc++.h>
#define ls cur << 1
#define rs cur << 1 | 1
#define rep(i, a, b) for(int i = (a); i <= (b); i ++ )
typedef long long ll;
using namespace std;
const int N = 5e3 + 10;
int main()
{
    ios ::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n; cin >> n;
    double i; cin >> i;
    double ans = 0;
    double A = 1;
    for(int j = 0; j <= n; j ++ )
    {
    	int x; cin >> x;
    	ans += x * (1 / A);
    	A = A  * (i + 1);
	}
    cout << ans;

	return 0;
}
原文