2020百度之星 初赛一 HDU-6744 GPA

1002题

暴力搜索
第一次写的时候 四门score相加<=x 那里落下了 ‘=’

#include 
using namespace std;

int score[] {95, 90, 85, 80, 75, 70, 67, 65, 62, 60, 0};
double point[] {4.3, 4.0, 3.7, 3.3, 3.0, 2.7, 2.3, 2.0, 1.7, 1.0, 0};

int main()
{
    int test;
    cin>>test;
    while(test--){
        int x; cin>>x; double ans=0;
        // 四门课 依次
        for(int i=0; i<11; i++)
            for(int j=0; j<11; j++)
                for(int k=0; k<11; k++)
                    for(int t=0; t<11; t++)
                        if(score[i]+score[j]+score[k]+score[t]<=x)
                            ans=max(ans, point[i]+point[j]+point[k]+point[t]);
                    
        printf("%.1lf\n", ans);
    }

    //system("pause");

    return 0;
}

你可能感兴趣的:(2020暑假补题记录)