QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#228505#7639. Forbidden Setucup-team1055#AC ✓0ms3804kbC++202.6kb2023-10-28 13:38:112023-10-28 13:38:11

Judging History

This is the latest submission verdict.

  • [2023-10-28 13:38:11]
  • Judged
  • Verdict: AC
  • Time: 0ms
  • Memory: 3804kb
  • [2023-10-28 13:38:11]
  • Submitted

answer

#include <bits/stdc++.h>

#define rep(i,s,n) for(int i = int(s); i < int(n); i++)
#define rrep(i,s,n) for(int i = int(n) - 1; i >= int(s); i--)
#define all(v) (v).begin(), (v).end()

using ll = long long;
using ld = long double;
using ull = unsigned long long;

template<class T>
bool chmin(T &a, T b) {
    if(a <= b) return false;
    a = b;
    return true;
}

template<class T>
bool chmax(T &a, T b) {
    if(a >= b) return false;
    a = b;
    return true;
}

using namespace std;

bool is_prime(int n){
    for (int d = 2; d * d <= n; d++){
        if (n % d == 0) return false;
    }
    return true;
}

const int iinf = 1e9+7;

void jikken() {
    int n; cin >> n;
    vector<bool> a(1<<10,false);
    for (int p = 2; p <= n; p++){
        if (!is_prime(p)) continue;
        int s = 0;
        int x = p;
        while (x > 0){
            s |= (1<<(x%10));
            x /= 10;
        }
        a[(1<<10) - 1 - s] = true;
        //cout << p << " " << s << endl;
    }
    rep(i,0,10){
        rep(s,0,1<<10){
            if ((s >> i & 1) == 1){
                if (a[s]) a[s^(1<<i)] = true;
            }
        }
    }
    auto get = [](int s, int i){
        return s >> i & 1;
    };
    rep(s,0,1<<10){
        if (popcount((unsigned int)(s)) >= 9) continue;
        if (get(s,1) + get(s,2) + get(s,3) + get(s,5) + get(s,7) + get(s,9) == 6) continue;
        if (!a[s]) cout << s << " " << bitset<10>(s).to_string() << endl;
    }
}

int main(){
    auto get = [](int s, int i){
        return s >> i & 1;
    };
    int n; cin >> n;
    int s = 0;
    rep(i,0,n){
        int d; cin >> d;
        s ^= (1<<d);
    }
    for (int p = 2; p <= 1000; p++){
        if (!is_prime(p)) continue;
        int t = 0;
        int x = p;
        while (x > 0){
            t |= (1<<(x%10));
            x /= 10;
        }
        if (t & s) continue;
        cout << p << endl;
        return 0;
    }
    cout << -1 << endl;
    // bool ex1 = popcount((unsigned int)(s)) >= 9;
    // bool ex2 = get(s,1) + get(s,2) + get(s,3) + get(s,5) + get(s,7) + get(s,9) == 6;
    // bool ex3 = (s == 446 || s == 447 || s == 510);
    // if (ex1 || ex2 || ex3){
    //     cout << -1 << endl;
    //     return 0;
    // }
    // for (int p = 2; p <= 1000; p++){
    //     if (!is_prime(p)) continue;
    //     int t = 0;
    //     int x = p;
    //     while (x > 0){
    //         t |= (1<<(x%10));
    //         x /= 10;
    //     }
    //     if (t & s) continue;
    //     cout << p << endl;
    //     return 0;
    // }
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

7
0
1
2
4
6
8
9

output:

3

result:

ok 1 number(s): "3"

Test #2:

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

input:

9
0
1
2
3
5
6
7
8
9

output:

-1

result:

ok 1 number(s): "-1"

Test #3:

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

input:

9
0
2
3
4
5
6
7
8
9

output:

11

result:

ok 1 number(s): "11"

Test #4:

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

input:

9
0
1
3
4
5
6
7
8
9

output:

2

result:

ok 1 number(s): "2"

Test #5:

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

input:

9
0
1
2
4
5
6
7
8
9

output:

3

result:

ok 1 number(s): "3"

Test #6:

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

input:

9
0
1
2
3
4
6
7
8
9

output:

5

result:

ok 1 number(s): "5"

Test #7:

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

input:

9
0
1
2
3
4
5
7
8
9

output:

-1

result:

ok 1 number(s): "-1"

Test #8:

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

input:

9
0
1
2
3
4
5
6
8
9

output:

7

result:

ok 1 number(s): "7"

Test #9:

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

input:

9
0
1
2
3
4
5
6
7
9

output:

-1

result:

ok 1 number(s): "-1"

Test #10:

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

input:

9
0
1
2
3
4
5
6
7
8

output:

-1

result:

ok 1 number(s): "-1"

Test #11:

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

input:

4
1
3
7
9

output:

2

result:

ok 1 number(s): "2"

Test #12:

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

input:

7
1
2
3
4
5
7
8

output:

-1

result:

ok 1 number(s): "-1"

Test #13:

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

input:

8
0
1
2
3
4
5
7
8

output:

-1

result:

ok 1 number(s): "-1"

Test #14:

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

input:

8
1
2
3
4
5
6
7
8

output:

-1

result:

ok 1 number(s): "-1"

Test #15:

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

input:

5
1
2
3
5
7

output:

89

result:

ok 1 number(s): "89"

Test #16:

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

input:

6
1
2
3
5
7
8

output:

409

result:

ok 1 number(s): "409"

Test #17:

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

input:

8
0
1
2
3
5
6
7
8

output:

449

result:

ok 1 number(s): "449"

Test #18:

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

input:

5
2
3
5
7
9

output:

11

result:

ok 1 number(s): "11"

Test #19:

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

input:

6
1
2
4
5
7
8

output:

3

result:

ok 1 number(s): "3"

Test #20:

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

input:

8
0
1
2
4
5
7
8
9

output:

3

result:

ok 1 number(s): "3"

Test #21:

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

input:

8
0
1
3
5
6
7
8
9

output:

2

result:

ok 1 number(s): "2"

Test #22:

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

input:

8
0
2
3
5
6
7
8
9

output:

11

result:

ok 1 number(s): "11"

Test #23:

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

input:

8
0
2
4
5
6
7
8
9

output:

3

result:

ok 1 number(s): "3"

Test #24:

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

input:

7
0
2
3
5
6
7
8

output:

11

result:

ok 1 number(s): "11"

Test #25:

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

input:

8
2
3
4
5
6
7
8
9

output:

11

result:

ok 1 number(s): "11"

Test #26:

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

input:

8
0
1
2
5
6
7
8
9

output:

3

result:

ok 1 number(s): "3"

Test #27:

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

input:

1
2

output:

3

result:

ok 1 number(s): "3"

Test #28:

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

input:

10
0
1
2
3
4
5
6
7
8
9

output:

-1

result:

ok 1 number(s): "-1"

Test #29:

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

input:

7
0
2
3
5
6
8
9

output:

7

result:

ok 1 number(s): "7"

Test #30:

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

input:

8
1
2
3
4
5
6
7
9

output:

-1

result:

ok 1 number(s): "-1"

Test #31:

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

input:

4
0
2
6
7

output:

3

result:

ok 1 number(s): "3"

Test #32:

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

input:

5
2
3
4
6
8

output:

5

result:

ok 1 number(s): "5"

Test #33:

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

input:

6
0
2
3
4
5
8

output:

7

result:

ok 1 number(s): "7"

Test #34:

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

input:

3
1
5
7

output:

2

result:

ok 1 number(s): "2"

Test #35:

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

input:

3
1
4
9

output:

2

result:

ok 1 number(s): "2"

Test #36:

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

input:

6
2
3
4
6
7
9

output:

5

result:

ok 1 number(s): "5"

Test #37:

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

input:

7
1
2
3
4
5
6
8

output:

7

result:

ok 1 number(s): "7"

Test #38:

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

input:

6
0
1
3
5
8
9

output:

2

result:

ok 1 number(s): "2"

Test #39:

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

input:

3
1
3
4

output:

2

result:

ok 1 number(s): "2"

Test #40:

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

input:

4
1
5
6
9

output:

2

result:

ok 1 number(s): "2"

Test #41:

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

input:

7
0
2
3
5
6
7
9

output:

11

result:

ok 1 number(s): "11"

Test #42:

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

input:

4
0
3
7
9

output:

2

result:

ok 1 number(s): "2"

Extra Test:

score: 0
Extra Test Passed