QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#600659#973. Composite Sequencefractal#WA 1ms3716kbC++171.3kb2024-09-29 18:08:292024-09-29 18:08:29

Judging History

This is the latest submission verdict.

  • [2024-09-29 18:08:29]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 3716kb
  • [2024-09-29 18:08:29]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;

#define F first
#define S second
#define sz(x) (int)x.size()

const int N = 1e5 + 200;

int n, a[N];
bool check(long long x) {
    for (long long i = 2; i * i <= x; ++i) {
        if (x % i == 0) {
            return true;
        }
    }
    return false;
}

int main() {
    cin.tie(0)->sync_with_stdio(0);
    cin >> n;
    int cnt1 = 0, cnt2 = 0, odd = 0;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
        cnt1 += a[i] == 1;
        cnt2 += a[i] == 2;
        odd += (a[i] % 2 == 1 && a[i] > 1);
    }
    for (int i = 1; i <= n; ++i) {
        if (a[i] > 2 && a[i] % 2 == 0) {
            cout << "Yes\n";
            return 0;
        }
        if (cnt1 > 0 && a[i] > 2 && a[i] % 2 == 1) {
            cout << "Yes\n";
            return 0;
        }
    }
    if (cnt2 > 1 || cnt1 > 3 || odd > 1) {
        cout << "Yes\n";
        return 0;
    }
    assert(n <= 5);
    for (int mask = 1; mask < (1<<n); ++mask) {
        long long sum = 0;
        for (int i = 0; i < n; ++i) {
            if ((mask >> i) & 1) {
                sum += a[i];
            }
        }
        if (check(sum)) {
            cout << "Yes\n";
            return 0;
        }
    }
    cout << "No\n";
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

2
5 7

output:

Yes

result:

ok "Yes"

Test #2:

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

input:

1
97

output:

No

result:

ok "No"

Test #3:

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

input:

1
97

output:

No

result:

ok "No"

Test #4:

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

input:

3
1 1 1

output:

No

result:

ok "No"

Test #5:

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

input:

4
1 1 1 1

output:

Yes

result:

ok "Yes"

Test #6:

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

input:

5
1 1 1 1 1

output:

Yes

result:

ok "Yes"

Test #7:

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

input:

2
1 2

output:

No

result:

ok "No"

Test #8:

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

input:

1
842538847

output:

No

result:

ok "No"

Test #9:

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

input:

1
211843267

output:

No

result:

ok "No"

Test #10:

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

input:

1
398694137

output:

No

result:

ok "No"

Test #11:

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

input:

1
370063921

output:

No

result:

ok "No"

Test #12:

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

input:

1
794328203

output:

No

result:

ok "No"

Test #13:

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

input:

1
4569743

output:

No

result:

ok "No"

Test #14:

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

input:

1
84242507

output:

No

result:

ok "No"

Test #15:

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

input:

1
627620321

output:

No

result:

ok "No"

Test #16:

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

input:

1
112813361

output:

No

result:

ok "No"

Test #17:

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

input:

1
467803799

output:

No

result:

ok "No"

Test #18:

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

input:

2
2 816177959

output:

No

result:

ok "No"

Test #19:

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

input:

2
2 833756321

output:

No

result:

ok "No"

Test #20:

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

input:

2
2 869570201

output:

No

result:

ok "No"

Test #21:

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

input:

2
2 803874569

output:

No

result:

ok "No"

Test #22:

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

input:

2
2 855615191

output:

No

result:

ok "No"

Test #23:

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

input:

2
2 816406499

output:

No

result:

ok "No"

Test #24:

score: -100
Wrong Answer
time: 0ms
memory: 3656kb

input:

2
2 875685741

output:

No

result:

wrong answer 1st words differ - expected: 'Yes', found: 'No'