湖大新生杯重现赛(一)

链接:https://ac.nowcoder.com/acm/contest/3674/D
来源:牛客网

Xuxu is a student who likes English and skirt.Therefore, he has spent a lot of time preparing for CET. CET is a very important test, which determines the style of Xuxu's skirt this year.

Xuxu just finished the CET and got the standard answer after that. What's more , if Xuxu gets zero,(如果得到0分) he will wear a skirt to the party, otherwise he will wear a suit(which is very disappointing). So Xuxu wants to know if it is possible for him to wear a skirt to the party. But unfortunately, he only remembers how many A, B, C and D he has written. Can you tell him weather he can wear a skirt in the party ?

输入描述:

The first line contains an integer n which indicates the number of questions.
The second line contain a string s which indicates the answer of each question.The answer only contain the upper case letters 'A','B','C' and 'D'.
The third line contain four integer a,b,c,d indicates the number of A,B,C,D Xuxu has written.

输出描述:

这里才是重点
If it's impossible for Xuxu to wear skirt, output the minimum number of questions Xuxu may answer correctly, Otherwise output "orz"

翻译一下:
若对于徐徐来说穿裙子是不可能的话,请输出他起码能答对多少,否则请输出"orz"

#include 
#include 
#include 
using namespace std;
int main() {
    int n;
    ios::sync_with_stdio(false);
    cin>>n;
    int s[4] = {0,0,0,0};
    string c;
    cin>>c;
    for(int i=0;i>ans[i];
    }
    if(ans[0]>s[1]+s[2]+s[3]){
        cout<s[0]+s[2]+s[3]){
        cout<s[1]+s[0]+s[3]){
        cout<s[1]+s[2]+s[0]){
        cout<

思路:

常规的输入其实是没问题的,这题难就难在如何输出

int n;
    ios::sync_with_stdio(false);
    cin>>n;
    int s[4] = {0,0,0,0};
    string c;
    cin>>c;
    for(int i=0;i>ans[i];
    }

输出部分我们仔细看看

    //若这个某人选的某个选项大于其他标准答案选项之和,那么这个人估计对得不多了,只能答对他选的选项减去其他标准答案之和
    if(ans[0]>s[1]+s[2]+s[3]){
        cout<s[0]+s[2]+s[3]){
        cout<s[1]+s[0]+s[3]){
        cout<s[1]+s[2]+s[0]){
        cout<

这里应该要联想到现实生活。这里举个例子:有10道选择题,标准答案是4A、3B、1C、2D。很遗憾你的答案是7A、其他选项各一个。这时你自己算一下自己分数。
假设你的BCD都写到应该填A那里了,那你就只剩下1个A,一定对。算法就是:4-3=1。
也可以是:7-6=1,这里就应该理解成即使其他本来不填A的我都填了A,但我还是能对1个。
但假如你没有一个选项时超过其他选项的标准答案之和的,那你很可能就要挂科了。

你可能感兴趣的:(湖大新生杯重现赛(一))