20分求助
查看原帖
20分求助
1054257
AndyCGM楼主2023/10/16 22:09
#include <iostream>
using namespace std;
int a[10],b[10];
int main(){
    int n;
    cin >> n;
    for (int i=0; i<n; i++){
        cin >> a[i] >> b[i];
    }
    int k;
    cin >> k;
    int nowpts=0;
    for (int i=0; i<n; i++){
        nowpts+=100/a[i]*b[i];
    }
    if (nowpts >= k){
        cout << "Already Au.";
        return 0;
    }
    for (int i=0; i<n; i++){
        int oneTP=100/a[i];
        if (nowpts+oneTP*(a[i]-b[i])<k){
            cout << "NaN" << endl;
        }
        else{
            for (int i=1; i<=b[i]; i++){
                nowpts+=oneTP;
                if (nowpts >= k){
                    cout << i << endl;
                    nowpts-=i*oneTP;
                    break;
                }
            }
        }
    }
}
2023/10/16 22:09
加载中...