Task: | Taulukot |
Sender: | |
Submission time: | 2015-10-09 21:03:33 +0300 |
Language: | C++ |
Status: | READY |
Result: | 100 |
group | verdict | score |
---|---|---|
#1 | ACCEPTED | 26 |
#2 | ACCEPTED | 29 |
#3 | ACCEPTED | 45 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | ACCEPTED | 0.05 s | 1 | details |
#2 | ACCEPTED | 0.05 s | 1 | details |
#3 | ACCEPTED | 0.05 s | 1 | details |
#4 | ACCEPTED | 0.05 s | 1 | details |
#5 | ACCEPTED | 0.05 s | 1 | details |
#6 | ACCEPTED | 0.06 s | 2 | details |
#7 | ACCEPTED | 0.05 s | 2 | details |
#8 | ACCEPTED | 0.05 s | 2 | details |
#9 | ACCEPTED | 0.05 s | 2 | details |
#10 | ACCEPTED | 0.05 s | 2 | details |
#11 | ACCEPTED | 1.04 s | 3 | details |
#12 | ACCEPTED | 1.45 s | 3 | details |
#13 | ACCEPTED | 1.38 s | 3 | details |
#14 | ACCEPTED | 1.25 s | 3 | details |
#15 | ACCEPTED | 1.10 s | 3 | details |
Code
#include <bits/stdc++.h>#define F first#define S secondusing namespace std;typedef long long ll;typedef long double ld;int ok[101010];int f[101010];int fp[101010];int isc[101010];int v1[101010];int v2[101010];int main(){ios_base::sync_with_stdio(0);cin.tie(0);int n;cin>>n;isc[0]=1;isc[1]=1;for (int i=2;i<=2*n;i++){if (!isc[i]){for (int j=i+i;j<=2*n;j+=i){isc[j]=1;}}}ok[0]=1;ok[1]=1;fp[1]=2;f[1]=0;for (int i=2;i<=n;i++){for (int j=i*2;j>i;j--){if (!isc[j]){if (ok[j-i-1]){ok[i]=1;f[i]=j-i-1;fp[i]=j;goto yli;}}}yli:;}int i2=0;int x=n;while (x>0){for (int i=x;i>f[x];i--){v1[i2]=fp[x]-i;v2[i2++]=i;}x=f[x];}for (int i=0;i<n;i++){cout<<v1[i]<<" ";}cout<<endl;for (int i=0;i<n;i++){cout<<v2[i]<<" ";}cout<<endl;}
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 |
---|
3 4 1 2 4 3 2 1 |
Test 3
Group: 1
Verdict: ACCEPTED
input |
---|
5 |
correct output |
---|
1 2 3 4 5 1 5 4 3 2 |
user output |
---|
2 3 4 5 1 5 4 3 2 1 |
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 |
---|
5 6 7 8 3 4 1 2 8 7 6 5 4 3 2 1 |
Test 5
Group: 1
Verdict: ACCEPTED
input |
---|
9 |
correct output |
---|
1 2 3 4 5 6 7 8 9 1 5 4 3 2 7 6 9 8 |
user output |
---|
8 9 6 7 2 3 4 5 1 9 8 7 6 5 4 3 2 1 |
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 |
---|
74 75 76 77 66 67 68 69 70 71 ... |
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 |
---|
69 70 63 64 65 66 67 68 51 52 ... |
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 |
---|
67 68 69 70 71 72 65 66 63 64 ... |
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 |
---|
81 82 83 84 85 86 77 78 79 80 ... |
Test 10
Group: 2
Verdict: ACCEPTED
input |
---|
68 |
correct output |
---|
1 2 3 4 5 6 7 8 9 10 11 12 13 ... |
user output |
---|
63 64 65 66 67 68 51 52 53 54 ... |
Test 11
Group: 3
Verdict: ACCEPTED
input |
---|
90764 |
correct output |
---|
1 2 3 4 5 6 7 8 9 10 11 12 13 ... |
user output |
---|
10257 10258 10259 10260 10261 ... |
Test 12
Group: 3
Verdict: ACCEPTED
input |
---|
97976 |
correct output |
---|
1 2 3 4 5 6 7 8 9 10 11 12 13 ... |
user output |
---|
3045 3046 3047 3048 3049 3050 ... |
Test 13
Group: 3
Verdict: ACCEPTED
input |
---|
96762 |
correct output |
---|
1 2 3 4 5 6 7 8 9 10 11 12 13 ... |
user output |
---|
4259 4260 4261 4262 4263 4264 ... |
Test 14
Group: 3
Verdict: ACCEPTED
input |
---|
94823 |
correct output |
---|
1 2 3 4 5 6 7 8 9 10 11 12 13 ... |
user output |
---|
6198 6199 6200 6201 6202 6203 ... |
Test 15
Group: 3
Verdict: ACCEPTED
input |
---|
91479 |
correct output |
---|
1 2 3 4 5 6 7 8 9 10 11 12 13 ... |
user output |
---|
9542 9543 9544 9545 9546 9547 ... |