QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#604960#2510. Make Numbersucup-team3474AC ✓1ms7832kbC++202.9kb2024-10-02 14:47:302024-10-02 14:47:31

Judging History

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

  • [2024-10-02 14:47:31]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:7832kb
  • [2024-10-02 14:47:30]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=1919810;
typedef long long ll;
typedef pair<ll,ll> PII;
ll n,m,k;
ll a[N],b[N];
char s[N];
int p[N];
set<int> se;



int main(){
    for(int i=1;i<=4;i++) cin>>a[i];
    for(int i=1;i<=4;i++) p[i]=i;
    do{ 
        for(int i=1;i<=4;i++) b[i]=a[p[i]];
        se.insert(b[1]+b[2]+b[3]+b[4]);
        se.insert(b[1]+b[2]+b[3]-b[4]);
        se.insert(b[1]+b[2]+b[3]*b[4]);
        se.insert(b[1]+b[2]-b[3]+b[4]);
        se.insert(b[1]+b[2]-b[3]-b[4]);
        se.insert(b[1]+b[2]-b[3]*b[4]);
        se.insert(b[1]+b[2]*b[3]+b[4]);
        se.insert(b[1]+b[2]*b[3]-b[4]);
        se.insert(b[1]+b[2]*b[3]*b[4]);


        
        se.insert(b[1]-b[2]+b[3]+b[4]);
        se.insert(b[1]-b[2]+b[3]-b[4]);
        se.insert(b[1]-b[2]+b[3]*b[4]);
        se.insert(b[1]-b[2]-b[3]+b[4]);
        se.insert(b[1]-b[2]-b[3]-b[4]);
        se.insert(b[1]-b[2]-b[3]*b[4]);
        se.insert(b[1]-b[2]*b[3]+b[4]);
        se.insert(b[1]-b[2]*b[3]-b[4]);
        se.insert(b[1]-b[2]*b[3]*b[4]);


        
        se.insert(b[1]*b[2]+b[3]+b[4]);
        se.insert(b[1]*b[2]+b[3]-b[4]);
        se.insert(b[1]*b[2]+b[3]*b[4]);
        se.insert(b[1]*b[2]-b[3]+b[4]);
        se.insert(b[1]*b[2]-b[3]-b[4]);
        se.insert(b[1]*b[2]-b[3]*b[4]);
        se.insert(b[1]*b[2]*b[3]+b[4]);
        se.insert(b[1]*b[2]*b[3]-b[4]);
        se.insert(b[1]*b[2]*b[3]*b[4]);
        
        int b12=b[1]*10+b[2],b23=b[2]*10+b[3],b34=b[3]*10+b[4];
        int b123=b12*10+b[3],b234=b23*10+b[4];
        se.insert(b12+b[3]+b[4]);
        se.insert(b12+b[3]-b[4]);
        se.insert(b12+b[3]*b[4]);
        se.insert(b12-b[3]+b[4]);
        se.insert(b12-b[3]-b[4]);
        se.insert(b12-b[3]*b[4]);
        se.insert(b12*b[3]+b[4]);
        se.insert(b12*b[3]-b[4]);
        se.insert(b12*b[3]*b[4]);

        se.insert(b[1]+b23+b[4]);
        se.insert(b[1]+b23-b[4]);
        se.insert(b[1]+b23*b[4]);
        se.insert(b[1]-b23+b[4]);
        se.insert(b[1]-b23-b[4]);
        se.insert(b[1]-b23*b[4]);
        se.insert(b[1]*b23+b[4]);
        se.insert(b[1]*b23-b[4]);
        se.insert(b[1]*b23*b[4]);
        
        se.insert(b[1]+b[2]+b34);
        se.insert(b[1]+b[2]-b34);
        se.insert(b[1]+b[2]*b34);
        se.insert(b[1]-b[2]+b34);
        se.insert(b[1]-b[2]-b34);
        se.insert(b[1]-b[2]*b34);
        se.insert(b[1]*b[2]+b34);
        se.insert(b[1]*b[2]-b34);
        se.insert(b[1]*b[2]*b34);

        se.insert(b12+b34);
        se.insert(b12-b34);
        se.insert(b12*b34);

        se.insert(b123+b[4]);
        se.insert(b123-b[4]);
        se.insert(b123*b[4]);

        se.insert(b[1]+b234);
        
        se.insert(b[1]-b234);
        
        se.insert(b[1]*b234);
    }while(next_permutation(p+1,p+1+4));
    int ans=0;
    for(auto x:se) if(x>=0) ans++;
    // cout<<endl; 
    cout<<ans;
}

详细

Test #1:

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

input:

1 1 1 1

output:

15

result:

ok single line: '15'

Test #2:

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

input:

1 1 1 1

output:

15

result:

ok single line: '15'

Test #3:

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

input:

1 1 2 1

output:

32

result:

ok single line: '32'

Test #4:

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

input:

1 2 4 8

output:

178

result:

ok single line: '178'

Test #5:

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

input:

1 3 3 8

output:

107

result:

ok single line: '107'

Test #6:

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

input:

1 1 2 1

output:

32

result:

ok single line: '32'

Test #7:

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

input:

2 2 4 4

output:

58

result:

ok single line: '58'

Test #8:

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

input:

2 3 4 5

output:

183

result:

ok single line: '183'

Test #9:

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

input:

2 3 5 7

output:

191

result:

ok single line: '191'

Test #10:

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

input:

2 4 6 8

output:

172

result:

ok single line: '172'

Test #11:

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

input:

2 5 5 5

output:

54

result:

ok single line: '54'

Test #12:

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

input:

2 8 6 4

output:

172

result:

ok single line: '172'

Test #13:

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

input:

3 3 3 3

output:

22

result:

ok single line: '22'

Test #14:

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

input:

5 3 2 7

output:

191

result:

ok single line: '191'

Test #15:

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

input:

5 7 8 9

output:

217

result:

ok single line: '217'

Test #16:

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

input:

9 9 9 9

output:

20

result:

ok single line: '20'