QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#499616#6728. To the ParkbuzhijingdiTL 2ms6384kbC++141.1kb2024-07-31 16:20:252024-07-31 16:20:26

Judging History

你现在查看的是最新测评结果

  • [2024-07-31 16:20:26]
  • 评测
  • 测评结果:TL
  • 用时:2ms
  • 内存:6384kb
  • [2024-07-31 16:20:25]
  • 提交

answer

#include<bits/stdc++.h>
#define int  long long
using namespace std;
int vis[100010];
int pri[100000];
int ispri[100010];
int a[100010];
void solve()
{
    memset(a,0,sizeof a);
    int n;
    cin>>n;
    if(n<4){cout<<0<<" "<<endl;
    return ;}
    int cnt=0;
    if(n>=4)for(int i=n;i>=2;i--){
        if(!ispri[i]){
            for(int j=(i+1)/2;j>=2;j--){
                if(i%j==0){
                    a[++cnt]=i;
                    a[++cnt]=j;
                    break;
                }
            }
            
        }
    
    }
    cout<<n/2-1<<" ";
    for(int i=cnt;i>=1;i--)cout<<a[i]<<" ";
    cout<<endl;
}
signed main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int t;
    cin>>t;
    int n=100010;
    int cnt=0;
    for(int i=2;i<=n;i++){
        if(!vis[i]){
            ispri[i]=1;
            pri[++cnt]=i;
            vis[i]=1;
            for(int j=1;i*pri[j]<=n;j++){
                vis[i*pri[j]]=1;
                if(i%pri[j]==0)break;
            }
        }
    }
    while(t--)
    solve();
    
    
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 6384kb

input:

3
1
4
6

output:

0 
1 2 4 
2 2 4 3 6 

result:

ok 4 cases

Test #2:

score: -100
Time Limit Exceeded

input:

1007
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101...

output:

0 
0 
0 
1 2 4 
1 2 4 
2 2 4 3 6 
2 2 4 3 6 
3 2 4 3 6 
3 2 4 3 6 3 9 
4 2 4 3 6 3 9 5 10 
4 2 4 3 6 3 9 5 10 
5 2 4 3 6 3 9 5 10 
5 2 4 3 6 3 9 5 10 
6 2 4 3 6 3 9 5 10 7 14 
6 2 4 3 6 3 9 5 10 7 14 5 15 
7 2 4 3 6 3 9 5 10 7 14 5 15 8 16 
7 2 4 3 6 3 9 5 10 7 14 5 15 8 16 
8 2 4 3 6 3 9 5 10 7 14 ...

result: