UOJ Logo

NOI.AC

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#206417#3706. 火柴棒等式Allen123456hello1004ms1188kbC++111.1kb2024-07-22 18:21:242024-07-22 20:06:47

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int arr[25]={0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,8,9,6,9,29,39,38,65,88,128};
/*
int arr[10]={6,2,5,5,4,5,6,3,7,6},ans;
set< pair< string,pair<string,string> > > ss;
bool check(vector<int> a[3]){
    string s[3];
    for (int i=0;i<3;++i){
        for (auto &&j : a[i]){
            s[i]+=(char)(j^48);
        }
    }
    if ((stoll(s[0])+stoll(s[1]))!=stoll(s[2])){return 0;}
    if (ss.count({s[0],{s[1],s[2]}})){return 0;}
    ss.insert({s[0],{s[1],s[2]}});
    return 1;
}
void dfs(int x,vector<int> a[3]){
    if (!x){
        if (a[0].empty()||a[1].empty()||a[2].empty()){return;}
        if (check(a)){++ans;}return;
    }
    for (int i=0;i<=9;++i){
        for (int j=0;j<3;++j){
            if (((a[j].empty())||(a[j][0]))&&(x>=arr[i])){
                a[j].emplace_back(i);
                dfs(x-arr[i],a);
                a[j].pop_back();
            }
        }
    }
    return;
}
vector<int> a[3];
*/
int main(){
    int n;
    scanf("%d",&n);
    /*
    dfs(max(n-4,0),a);
    printf("%d",ans);
    */
    printf("%d",arr[n]);
    return 0;
}

Details

小提示:点击横条可展开更详细的信息

Test #1:

score: 4
Accepted
time: 0ms
memory: 1188kb

input:

1

output:

0

result:

ok single line: '0'

Test #2:

score: 4
Accepted
time: 0ms
memory: 1184kb

input:

2

output:

0

result:

ok single line: '0'

Test #3:

score: 4
Accepted
time: 0ms
memory: 1184kb

input:

3

output:

0

result:

ok single line: '0'

Test #4:

score: 4
Accepted
time: 0ms
memory: 1188kb

input:

4

output:

0

result:

ok single line: '0'

Test #5:

score: 4
Accepted
time: 0ms
memory: 1184kb

input:

5

output:

0

result:

ok single line: '0'

Test #6:

score: 4
Accepted
time: 0ms
memory: 1184kb

input:

6

output:

0

result:

ok single line: '0'

Test #7:

score: 4
Accepted
time: 0ms
memory: 1188kb

input:

7

output:

0

result:

ok single line: '0'

Test #8:

score: 4
Accepted
time: 0ms
memory: 1184kb

input:

8

output:

0

result:

ok single line: '0'

Test #9:

score: 4
Accepted
time: 0ms
memory: 1188kb

input:

9

output:

0

result:

ok single line: '0'

Test #10:

score: 4
Accepted
time: 1ms
memory: 1184kb

input:

10

output:

0

result:

ok single line: '0'

Test #11:

score: 4
Accepted
time: 1ms
memory: 1188kb

input:

11

output:

0

result:

ok single line: '0'

Test #12:

score: 4
Accepted
time: 0ms
memory: 1184kb

input:

12

output:

0

result:

ok single line: '0'

Test #13:

score: 4
Accepted
time: 0ms
memory: 1188kb

input:

13

output:

1

result:

ok single line: '1'

Test #14:

score: 4
Accepted
time: 0ms
memory: 1188kb

input:

14

output:

2

result:

ok single line: '2'

Test #15:

score: 4
Accepted
time: 0ms
memory: 1188kb

input:

15

output:

8

result:

ok single line: '8'

Test #16:

score: 4
Accepted
time: 0ms
memory: 1184kb

input:

16

output:

9

result:

ok single line: '9'

Test #17:

score: 4
Accepted
time: 0ms
memory: 1184kb

input:

17

output:

6

result:

ok single line: '6'

Test #18:

score: 4
Accepted
time: 0ms
memory: 1188kb

input:

18

output:

9

result:

ok single line: '9'

Test #19:

score: 4
Accepted
time: 0ms
memory: 1188kb

input:

19

output:

29

result:

ok single line: '29'

Test #20:

score: 4
Accepted
time: 0ms
memory: 1188kb

input:

20

output:

39

result:

ok single line: '39'

Test #21:

score: 4
Accepted
time: 0ms
memory: 1188kb

input:

21

output:

38

result:

ok single line: '38'

Test #22:

score: 4
Accepted
time: 0ms
memory: 1184kb

input:

22

output:

65

result:

ok single line: '65'

Test #23:

score: 4
Accepted
time: 2ms
memory: 1188kb

input:

23

output:

88

result:

ok single line: '88'

Test #24:

score: 4
Accepted
time: 0ms
memory: 1184kb

input:

24

output:

128

result:

ok single line: '128'