QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#123266#235. Maximum Multiplelarush0 0ms0kbC++17865b2023-07-11 23:16:392023-07-11 23:16:42

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-11 23:16:42]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:0kb
  • [2023-07-11 23:16:39]
  • 提交

answer

#include <bits/stdc++.h>
#define debug(x) (cout<<'['<<(#x)<<':'<<(x)<<']'<<'\n')
using namespace std;

int main(){
    ios::sync_with_stdio(0), cin.tie(0);

    int tt;
    cin>>tt;
    while(tt--){
        int n;
        cin>>n;
        vector<int> div;
        set<int> s;
        for(int i=1; i*i<=n; i++){
            if(n%i==0){
                div.push_back(i);
                if(i!=n/i) div.push_back(n/i);
            }
        }
        int res=-1;
        sort(div.begin(),div.end());
        for(int i=0; i<div.size(); i++) s.insert(div[i]);
        for(int i=0; i<n; i++){
            for(int j=i; j<n; j++){
                int k=n-div[i]-div[j];
                if(s.count(k)){
                    res=max(res,div[i]*div[j]*k);
                }
            }
        }
        cout<<res<<'\n';
    }
    return 0;
}

详细

Test #1:

score: 0
Time Limit Exceeded

input:

1000000
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
...

output:

-1
-1
1
2
0
8
0
16
27
0
0
64
0
0
125
128
0
216
0
250
343
0
0
512
0
0
729
686
96
1000
225
1024
1331
510
1125
1728
0
0
2197
2000
0
2744
0
2662
3375
0
529
4096
0
0
4913
4394
676
5832
3993
5488
6859
0
841
8000
0
0
9261
8192
1911
10648
0
9826
12167
4802
1225
13824
0
72
15625
13718
1444
17576
0
16000
1968...

result: