QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#254453#2510. Make Numberstpc_icpc_n#AC ✓1ms3812kbC++201.4kb2023-11-18 12:42:192023-11-18 12:42:19

Judging History

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

  • [2023-11-18 12:42:19]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:3812kb
  • [2023-11-18 12:42:19]
  • 提交

answer

#include <iostream>
#include <vector>
#include <set>
#include <unordered_set>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;



int main() {
    int N = 4;
    std::vector<int> A(N);
    for(int i = 0; i < N; i++) {
        std::cin >> A[i];
    }
    std::vector<int> p = { 0, 0, 1, 2 };
    std::unordered_set<int> st;
    std::sort(A.begin(), A.end());
    do {
    rep(a, 4) rep(b, 4) rep(c, 4) {
        if(a == b && b == c && c == 3) continue;
        std::vector<int> op = { a, b, c };
        std::vector<int> x = A;
        while(x.size() > 1) {
            int i = 0;
            for(int j = 1; j < op.size(); j++) {
                if(p[op[i]] < p[op[j]]) {
                    i = j;
                }
            }
            int ans = 0;
            if(op[i] == 0) {
                ans = x[i] + x[i + 1];
            }
            else if(op[i] == 1) {
                ans = x[i] - x[i + 1];
            }
            else if(op[i] == 2) {
                ans = x[i] * x[i + 1];
            }
            else {
                ans = x[i] * 10 + x[i + 1];
            }
            x[i] = ans;
            x.erase(x.begin() + i + 1);
            op.erase(op.begin() + i);
        }
        if(x.front() >= 0) {
            st.insert(x.front());
        }
    }
    } while(std::next_permutation(A.begin(), A.end()));
    using i64 = long long;
    std::cout << st.size() << std::endl;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3588kb

input:

1 1 1 1

output:

15

result:

ok single line: '15'

Test #2:

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

input:

1 1 1 1

output:

15

result:

ok single line: '15'

Test #3:

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

input:

1 1 2 1

output:

32

result:

ok single line: '32'

Test #4:

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

input:

1 2 4 8

output:

178

result:

ok single line: '178'

Test #5:

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

input:

1 3 3 8

output:

107

result:

ok single line: '107'

Test #6:

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

input:

1 1 2 1

output:

32

result:

ok single line: '32'

Test #7:

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

input:

2 2 4 4

output:

58

result:

ok single line: '58'

Test #8:

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

input:

2 3 4 5

output:

183

result:

ok single line: '183'

Test #9:

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

input:

2 3 5 7

output:

191

result:

ok single line: '191'

Test #10:

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

input:

2 4 6 8

output:

172

result:

ok single line: '172'

Test #11:

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

input:

2 5 5 5

output:

54

result:

ok single line: '54'

Test #12:

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

input:

2 8 6 4

output:

172

result:

ok single line: '172'

Test #13:

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

input:

3 3 3 3

output:

22

result:

ok single line: '22'

Test #14:

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

input:

5 3 2 7

output:

191

result:

ok single line: '191'

Test #15:

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

input:

5 7 8 9

output:

217

result:

ok single line: '217'

Test #16:

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

input:

9 9 9 9

output:

20

result:

ok single line: '20'