| Task: | Alkuluvut |
| Sender: | Kuha |
| Submission time: | 2025-09-27 17:16:22 +0300 |
| Language: | C++ (C++11) |
| Status: | READY |
| Result: | 100 |
| group | verdict | score |
|---|---|---|
| #1 | ACCEPTED | 17 |
| #2 | ACCEPTED | 41 |
| #3 | ACCEPTED | 42 |
| test | verdict | time | group | |
|---|---|---|---|---|
| #1 | ACCEPTED | 0.01 s | 1, 2, 3 | details |
| #2 | ACCEPTED | 0.02 s | 2, 3 | details |
| #3 | ACCEPTED | 0.60 s | 3 | details |
Compiler report
input/code.cpp: In function 'int main()':
input/code.cpp:35:29: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
35 | while (w.size() != len) w.push_back(w[rand() % k]);
| ~~~~~~~~~^~~~~~Code
#include <bits/stdc++.h>
#define ll long long
using namespace std;
bool prime(ll n) {
if (n <= 1) return false;
for (ll i = 2; i * i <= n; i++) {
if (n % i == 0) return false;
}
return true;
}
int main() {
srand(time(0));
int t;
cin>>t;
while (t --> 0) {
int k;
cin>>k;
vector<ll> v;
for (int i = 0; i < k; i++) {
int x;
cin>>x;
if (k == 1 && x == 0) {
cout<<"NO"<<endl;
goto end;
}
v.push_back(x);
}
for (int it = 0; it < 1000; it++) {
vector<ll> w = v;
int len = min(12, k + (rand() % 6));
while (w.size() != len) w.push_back(w[rand() % k]);
random_shuffle(w.begin(), w.end());
while (w[0] == 0) {
random_shuffle(w.begin(), w.end());
}
ll p = 0;
for (ll x : w) {
p = 10 * p + x;
}
if (prime(p)) {
cout<<"YES"<<endl;
cout<<p<<endl;
goto end;
}
}
cout<<"NO"<<endl;
end:;
}
}Test details
Test 1
Group: 1, 2, 3
Verdict: ACCEPTED
| input |
|---|
| 10 1 0 1 1 ... |
| correct output |
|---|
| NO YES 11 YES 2 ... |
| user output |
|---|
| NO YES 11 YES 2 ... |
Test 2
Group: 2, 3
Verdict: ACCEPTED
| input |
|---|
| 175 1 0 1 1 ... |
| correct output |
|---|
| NO YES 11 YES 2 ... |
| user output |
|---|
| NO YES 11 YES 2 ... Truncated |
Test 3
Group: 3
Verdict: ACCEPTED
| input |
|---|
| 848 4 0 1 2 3 4 0 1 2 4 ... |
| correct output |
|---|
| YES 10223 YES 4021 YES ... |
| user output |
|---|
| YES 123102103 YES 201401 YES ... Truncated |
