80pts求助

P1968 美元汇率

wangjue233 @ 2023-10-24 17:08:04

80pts 错误样例#2: 输入: 5 150 200 220 230 500 正确输出: 100.00 我的程序输出:75.00

我的程序:

#include<iostream>
#include<iomanip>
#define LF double
using namespace std;
const int maxn = 100 + 10;
LF my[maxn], mk[maxn];
int main(){
    int n; cin >> n;
    cin >> mk[1];
    for(int i = 2; i <= n; i++){
        int q; cin >> q;
        my[i] = max(my[i - 1], mk[i - 1] * 100.0 / q);
        mk[i] = max(mk[i - 1], my[i - 1] / 100.0 * q);
    }
    cout << fixed << setprecision(2) << my[n] << "\n";
    return 0;
}

不知道错哪里了,求dalao们帮帮这个蒟蒻吧//


by Breath_of_the_Wild @ 2023-10-24 17:34:58

初始化,my_1=100


by wangjue233 @ 2023-10-24 17:50:24

@Breath_of_the_Wild 谢谢dalao


|