QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#231113 | #7639. Forbidden Set | ucup-team1134# | AC ✓ | 2ms | 4248kb | C++17 | 1.4kb | 2023-10-29 02:10:58 | 2023-10-29 02:10:58 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=998244353,MAX=300005,INF=1<<30;
vector<int> prime;//i番目の素数
bool is_prime[MAX+1];
void sieve(int n){
for(int i=0;i<=n;i++){
is_prime[i]=true;
}
is_prime[0]=is_prime[1]=false;
for(int i=2;i<=n;i++){
if(is_prime[i]){
prime.push_back(i);
for(int j=2*i;j<=n;j+=i){
is_prime[j] = false;
}
}
}
}
int main(){
std::ifstream in("text.txt");
std::cin.rdbuf(in.rdbuf());
cin.tie(0);
ios::sync_with_stdio(false);
vector<int> NG(10);
int n;cin>>n;
for(int i=0;i<n;i++){
int x;cin>>x;
NG[x]=true;
}
sieve(MAX-2);
for(int p:prime){
string S=to_string(p);
bool ok=true;
for(char c:S){
ok&=(NG[c-'0']==0);
}
if(ok){
cout<<p<<endl;
return 0;
}
}
cout<<-1<<endl;
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 3968kb
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: 4072kb
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: 1ms
memory: 4004kb
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: 2ms
memory: 4244kb
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: 2ms
memory: 4248kb
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: 1ms
memory: 3964kb
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: 2ms
memory: 3912kb
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: 1ms
memory: 3964kb
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: 2ms
memory: 4020kb
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: 2ms
memory: 4216kb
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: 2ms
memory: 4036kb
input:
4 1 3 7 9
output:
2
result:
ok 1 number(s): "2"
Test #12:
score: 0
Accepted
time: 2ms
memory: 3964kb
input:
7 1 2 3 4 5 7 8
output:
-1
result:
ok 1 number(s): "-1"
Test #13:
score: 0
Accepted
time: 2ms
memory: 4028kb
input:
8 0 1 2 3 4 5 7 8
output:
-1
result:
ok 1 number(s): "-1"
Test #14:
score: 0
Accepted
time: 2ms
memory: 3968kb
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: 4224kb
input:
5 1 2 3 5 7
output:
89
result:
ok 1 number(s): "89"
Test #16:
score: 0
Accepted
time: 1ms
memory: 4244kb
input:
6 1 2 3 5 7 8
output:
409
result:
ok 1 number(s): "409"
Test #17:
score: 0
Accepted
time: 2ms
memory: 3968kb
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: 4172kb
input:
5 2 3 5 7 9
output:
11
result:
ok 1 number(s): "11"
Test #19:
score: 0
Accepted
time: 1ms
memory: 4248kb
input:
6 1 2 4 5 7 8
output:
3
result:
ok 1 number(s): "3"
Test #20:
score: 0
Accepted
time: 1ms
memory: 4036kb
input:
8 0 1 2 4 5 7 8 9
output:
3
result:
ok 1 number(s): "3"
Test #21:
score: 0
Accepted
time: 1ms
memory: 4176kb
input:
8 0 1 3 5 6 7 8 9
output:
2
result:
ok 1 number(s): "2"
Test #22:
score: 0
Accepted
time: 1ms
memory: 4240kb
input:
8 0 2 3 5 6 7 8 9
output:
11
result:
ok 1 number(s): "11"
Test #23:
score: 0
Accepted
time: 1ms
memory: 4068kb
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: 4220kb
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: 4068kb
input:
8 2 3 4 5 6 7 8 9
output:
11
result:
ok 1 number(s): "11"
Test #26:
score: 0
Accepted
time: 1ms
memory: 3912kb
input:
8 0 1 2 5 6 7 8 9
output:
3
result:
ok 1 number(s): "3"
Test #27:
score: 0
Accepted
time: 1ms
memory: 4012kb
input:
1 2
output:
3
result:
ok 1 number(s): "3"
Test #28:
score: 0
Accepted
time: 2ms
memory: 4028kb
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: 1ms
memory: 4028kb
input:
7 0 2 3 5 6 8 9
output:
7
result:
ok 1 number(s): "7"
Test #30:
score: 0
Accepted
time: 2ms
memory: 4024kb
input:
8 1 2 3 4 5 6 7 9
output:
-1
result:
ok 1 number(s): "-1"
Test #31:
score: 0
Accepted
time: 1ms
memory: 4028kb
input:
4 0 2 6 7
output:
3
result:
ok 1 number(s): "3"
Test #32:
score: 0
Accepted
time: 1ms
memory: 4072kb
input:
5 2 3 4 6 8
output:
5
result:
ok 1 number(s): "5"
Test #33:
score: 0
Accepted
time: 1ms
memory: 4024kb
input:
6 0 2 3 4 5 8
output:
7
result:
ok 1 number(s): "7"
Test #34:
score: 0
Accepted
time: 1ms
memory: 3968kb
input:
3 1 5 7
output:
2
result:
ok 1 number(s): "2"
Test #35:
score: 0
Accepted
time: 1ms
memory: 3912kb
input:
3 1 4 9
output:
2
result:
ok 1 number(s): "2"
Test #36:
score: 0
Accepted
time: 0ms
memory: 4172kb
input:
6 2 3 4 6 7 9
output:
5
result:
ok 1 number(s): "5"
Test #37:
score: 0
Accepted
time: 1ms
memory: 4076kb
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: 3968kb
input:
6 0 1 3 5 8 9
output:
2
result:
ok 1 number(s): "2"
Test #39:
score: 0
Accepted
time: 1ms
memory: 4020kb
input:
3 1 3 4
output:
2
result:
ok 1 number(s): "2"
Test #40:
score: 0
Accepted
time: 1ms
memory: 4072kb
input:
4 1 5 6 9
output:
2
result:
ok 1 number(s): "2"
Test #41:
score: 0
Accepted
time: 1ms
memory: 3964kb
input:
7 0 2 3 5 6 7 9
output:
11
result:
ok 1 number(s): "11"
Test #42:
score: 0
Accepted
time: 1ms
memory: 3968kb
input:
4 0 3 7 9
output:
2
result:
ok 1 number(s): "2"
Extra Test:
score: 0
Extra Test Passed