QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#591167#2510. Make Numbersmrkiencf#WA 1ms3876kbC++203.1kb2024-09-26 14:35:212024-09-26 14:35:23

Judging History

你现在查看的是最新测评结果

  • [2024-09-26 14:35:23]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3876kb
  • [2024-09-26 14:35:21]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

const int O = 2e5 + 5;

int n, a[4], b[4];
vector <int> res, id;

void Do(vector <int> c){
    if (c.size() == 1){
        //res.push_back(c[0]);
    }

    if (c.size() == 2){
        res.push_back(c[0] * c[1]);
        res.push_back(c[0] - c[1]);
        res.push_back(c[0] + c[1]);
    }

    if (c.size() == 3){
        res.push_back(c[0] * c[1] - c[2]);
        res.push_back(c[0] * c[1] + c[2]);
        res.push_back(c[0] * c[1] * c[2]);
        res.push_back(c[0] + c[1] - c[2]);
        res.push_back(c[0] + c[1] + c[2]);
        res.push_back(c[0] + c[1] * c[2]);
        res.push_back(c[0] - c[1] - c[2]);
        res.push_back(c[0] - c[1] + c[2]);
        res.push_back(c[0] - c[1] * c[2]);
    }

    if (c.size() == 4){
        res.push_back(c[0] * c[1] - c[2] + c[3]);
        res.push_back(c[0] * c[1] - c[2] - c[3]);
        res.push_back(c[0] * c[1] - c[2] * c[3]);
        res.push_back(c[0] * c[1] + c[2] + c[3]);
        res.push_back(c[0] * c[1] + c[2] - c[3]);
        res.push_back(c[0] * c[1] + c[2] * c[3]);
        res.push_back(c[0] * c[1] * c[2] + c[3]);
        res.push_back(c[0] * c[1] * c[2] - c[3]);
        res.push_back(c[0] * c[1] * c[2] * c[3]);

        res.push_back(c[0] - c[1] - c[2] + c[3]);
        res.push_back(c[0] - c[1] - c[2] - c[3]);
        res.push_back(c[0] - c[1] - c[2] * c[3]);
        res.push_back(c[0] - c[1] + c[2] + c[3]);
        res.push_back(c[0] - c[1] + c[2] - c[3]);
        res.push_back(c[0] - c[1] + c[2] * c[3]);
        res.push_back(c[0] - c[1] * c[2] + c[3]);
        res.push_back(c[0] - c[1] * c[2] - c[3]);
        res.push_back(c[0] - c[1] * c[2] * c[3]);

        res.push_back(c[0] + c[1] - c[2] + c[3]);
        res.push_back(c[0] + c[1] - c[2] - c[3]);
        res.push_back(c[0] + c[1] - c[2] * c[3]);
        res.push_back(c[0] + c[1] + c[2] + c[3]);
        res.push_back(c[0] + c[1] + c[2] - c[3]);
        res.push_back(c[0] + c[1] + c[2] * c[3]);
        res.push_back(c[0] + c[1] * c[2] + c[3]);
        res.push_back(c[0] + c[1] * c[2] - c[3]);
        res.push_back(c[0] + c[1] * c[2] * c[3]);
    }

}

void cal(int pos, int x, int lim){
    if (pos == 4){
        //b[lim] = x;
        vector <int> c;
        for (int i = 0; i < lim; ++ i){
            c.push_back(b[i]);
            //cout << b[i] << " ";
        }
        Do(c);
        //cout << endl;
        return;
    }

    b[lim] = x * 10 + a[id[pos]];
    cal(pos + 1, 0, lim + 1);
    cal(pos + 1, x * 10 + a[id[pos]], lim);
}

main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    for (int i = 0; i < 4; ++ i){
        id.push_back(i);
        cin >> a[i];
    }

    do {
        cal(0, 0, 0);
    } while(next_permutation(id.begin(), id.end()));

    sort(res.begin(), res.end());
    int m = unique(res.begin(), res.end()) - res.begin();
    res.resize(m);

    sort(res.rbegin(), res.rend());
    while (res.size() && res.back() < 0) res.pop_back();

    cout << res.size() << endl;
    //for (int i : res) cout << i << " ";
}
/**
 * 6
**/

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3876kb

input:

1 1 1 1

output:

15

result:

ok single line: '15'

Test #2:

score: 0
Accepted
time: 1ms
memory: 3836kb

input:

1 1 1 1

output:

15

result:

ok single line: '15'

Test #3:

score: 0
Accepted
time: 0ms
memory: 3620kb

input:

1 1 2 1

output:

32

result:

ok single line: '32'

Test #4:

score: -100
Wrong Answer
time: 1ms
memory: 3868kb

input:

1 2 4 8

output:

185

result:

wrong answer 1st lines differ - expected: '178', found: '185'