Task: | Taulukot |
Sender: | |
Submission time: | 2015-10-09 22:29:01 +0300 |
Language: | Java |
Status: | READY |
Result: | 0 |
group | verdict | score |
---|---|---|
#1 | WRONG ANSWER | 0 |
#2 | WRONG ANSWER | 0 |
#3 | TIME LIMIT EXCEEDED | 0 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | ACCEPTED | 0.17 s | 1 | details |
#2 | ACCEPTED | 0.18 s | 1 | details |
#3 | WRONG ANSWER | 0.17 s | 1 | details |
#4 | ACCEPTED | 0.16 s | 1 | details |
#5 | WRONG ANSWER | 0.17 s | 1 | details |
#6 | ACCEPTED | 0.17 s | 2 | details |
#7 | ACCEPTED | 0.18 s | 2 | details |
#8 | ACCEPTED | 0.17 s | 2 | details |
#9 | ACCEPTED | 0.19 s | 2 | details |
#10 | WRONG ANSWER | 0.17 s | 2 | details |
#11 | TIME LIMIT EXCEEDED | -- | 3 | details |
#12 | TIME LIMIT EXCEEDED | -- | 3 | details |
#13 | TIME LIMIT EXCEEDED | -- | 3 | details |
#14 | TIME LIMIT EXCEEDED | -- | 3 | details |
#15 | TIME LIMIT EXCEEDED | -- | 3 | details |
Code
//package alkuluvut; /** * * @author Adreno */ public class Alkuluvut { /** * @param args the command line arguments */ public static void main(String[] args) { IO io = new IO(); int n = io.nextInt(); boolean[] kaytettyA = new boolean[n+1]; boolean[] kaytettyB = new boolean[n+1]; int pointer = 0; int[] a = new int[n]; int[] b = new int[n]; for (int i=n; i>=1; i--) { if (kaytettyA[i] && kaytettyB[i]) continue; for (int j=i; j>=1; j--) { if ((kaytettyA[i] || kaytettyB[j]) && (kaytettyA[j] || kaytettyB[i])) continue; if (!onkoAlkuluku(i+j)) continue; if (!kaytettyA[i] && !kaytettyB[j]) { kaytettyA[i] = true; kaytettyB[j] = true; a[pointer] = i; b[pointer] = j; pointer++; } else {// if (!kaytettyA[j] && !kaytettyB[i]) { kaytettyA[j] = true; kaytettyB[i] = true; a[pointer] = j; b[pointer] = i; pointer++; } } } for (int i=0; i<n; i++) io.print(a[i] + " "); io.println(); for (int i=0; i<n; i++) io.print(b[i] + " "); io.println(); io.close(); } public static boolean onkoAlkuluku(int a) { for (int i=2; i*i<=a; i++) { if (a%i == 0) return false; } return true; } }
Test details
Test 1
Group: 1
Verdict: ACCEPTED
input |
---|
1 |
correct output |
---|
1 1 |
user output |
---|
1 1 |
Test 2
Group: 1
Verdict: ACCEPTED
input |
---|
4 |
correct output |
---|
1 2 3 4 2 1 4 3 |
user output |
---|
4 1 3 2 3 4 2 1 |
Test 3
Group: 1
Verdict: WRONG ANSWER
input |
---|
5 |
correct output |
---|
1 2 3 4 5 1 5 4 3 2 |
user output |
---|
5 4 1 2 0 2 3 4 1 0 |
Test 4
Group: 1
Verdict: ACCEPTED
input |
---|
8 |
correct output |
---|
1 2 3 4 5 6 7 8 2 1 4 3 8 7 6 5 |
user output |
---|
8 3 7 4 6 5 1 2 5 8 6 7 1 2 4 3 |
Test 5
Group: 1
Verdict: WRONG ANSWER
input |
---|
9 |
correct output |
---|
1 2 3 4 5 6 7 8 9 1 5 4 3 2 7 6 9 8 |
user output |
---|
9 4 8 7 6 5 3 2 0 8 9 5 6 1 2 4 3 0 |
Test 6
Group: 2
Verdict: ACCEPTED
input |
---|
77 |
correct output |
---|
1 2 3 4 5 6 7 8 9 10 11 12 13 ... |
user output |
---|
77 72 76 73 75 74 66 67 71 60 ... |
Test 7
Group: 2
Verdict: ACCEPTED
input |
---|
70 |
correct output |
---|
1 2 3 4 5 6 7 8 9 10 11 12 13 ... |
user output |
---|
70 67 69 68 64 66 61 65 63 62 ... |
Test 8
Group: 2
Verdict: ACCEPTED
input |
---|
72 |
correct output |
---|
1 2 3 4 5 6 7 8 9 10 11 12 13 ... |
user output |
---|
72 65 71 66 70 67 69 68 61 62 ... |
Test 9
Group: 2
Verdict: ACCEPTED
input |
---|
86 |
correct output |
---|
1 2 3 4 5 6 7 8 9 10 11 12 13 ... |
user output |
---|
86 77 85 78 84 79 83 82 81 80 ... |
Test 10
Group: 2
Verdict: WRONG ANSWER
input |
---|
68 |
correct output |
---|
1 2 3 4 5 6 7 8 9 10 11 12 13 ... |
user output |
---|
68 59 67 60 66 61 65 64 63 62 ... |
Test 11
Group: 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
90764 |
correct output |
---|
1 2 3 4 5 6 7 8 9 10 11 12 13 ... |
user output |
---|
(empty) |
Test 12
Group: 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
97976 |
correct output |
---|
1 2 3 4 5 6 7 8 9 10 11 12 13 ... |
user output |
---|
(empty) |
Test 13
Group: 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
96762 |
correct output |
---|
1 2 3 4 5 6 7 8 9 10 11 12 13 ... |
user output |
---|
(empty) |
Test 14
Group: 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
94823 |
correct output |
---|
1 2 3 4 5 6 7 8 9 10 11 12 13 ... |
user output |
---|
(empty) |
Test 15
Group: 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
91479 |
correct output |
---|
1 2 3 4 5 6 7 8 9 10 11 12 13 ... |
user output |
---|
(empty) |