답안 #458184

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
458184 2021-08-08T02:15:14 Z cpp219 Toys (CEOI18_toy) C++14
59 / 100
5000 ms 8668 KB
#pragma GCC optimization O2
#pragma GCC optimization "unroll-loop"
#pragma target ("avx2")

#include <bits/stdc++.h>
#define ll int
#define ld long double
#define fs first
#define sc second
using namespace std;
typedef pair<ll,ll> LL;
const ll N = 1e5 + 9;
const ll Log2 = 21;
const ll inf = 1e9 + 7;

map<LL,ll> mp;
vector<ll> uoc,ans;
ll n;

void f(ll rm,ll sum){
    //if (mp.count({rm,sum})) return;
    //mp[{rm,sum}] = 1;
    if (rm == 1){
        ans.push_back(sum); return;
    }
    for (auto i : uoc) if (rm % i == 0) f(rm/i,sum + i - 1);
}

int main(){
    ios_base::sync_with_stdio(NULL); cin.tie(0); cout.tie(0);
    #define task "tst"
    if (fopen(task".INP","r")){
        freopen(task".INP","r",stdin);
        //freopen(task".OUT","w",stdout);
    }
    cin>>n; uoc.push_back(n);
    for (ll i = 2;i <= n/i;i++){
        if (n%i == 0){
            uoc.push_back(i);
            if (n/i != i) uoc.push_back(n/i);
        }
    }
    f(n,0);
    sort(ans.begin(),ans.end()); ans.resize(unique(ans.begin(),ans.end()) - ans.begin());
    cout<<ans.size()<<"\n";
    for (auto i : ans) cout<<i<< " ";
}

Compilation message

toy.cpp:1: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    1 | #pragma GCC optimization O2
      | 
toy.cpp:2: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    2 | #pragma GCC optimization "unroll-loop"
      | 
toy.cpp:3: warning: ignoring '#pragma target ' [-Wunknown-pragmas]
    3 | #pragma target ("avx2")
      | 
toy.cpp: In function 'int main()':
toy.cpp:33:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |         freopen(task".INP","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 204 KB Output is correct
24 Correct 0 ms 204 KB Output is correct
25 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 204 KB Output is correct
24 Correct 0 ms 204 KB Output is correct
25 Correct 0 ms 204 KB Output is correct
26 Correct 10 ms 424 KB Output is correct
27 Correct 8 ms 460 KB Output is correct
28 Correct 2 ms 332 KB Output is correct
29 Correct 1 ms 332 KB Output is correct
30 Correct 1 ms 204 KB Output is correct
31 Correct 29 ms 944 KB Output is correct
32 Correct 13 ms 592 KB Output is correct
33 Correct 11 ms 536 KB Output is correct
34 Correct 1 ms 204 KB Output is correct
35 Correct 0 ms 204 KB Output is correct
36 Correct 1 ms 332 KB Output is correct
37 Correct 7 ms 460 KB Output is correct
38 Correct 1 ms 332 KB Output is correct
39 Correct 0 ms 204 KB Output is correct
40 Correct 5 ms 332 KB Output is correct
41 Correct 1 ms 204 KB Output is correct
42 Correct 1 ms 204 KB Output is correct
43 Correct 1 ms 204 KB Output is correct
44 Correct 1 ms 204 KB Output is correct
45 Correct 1 ms 204 KB Output is correct
46 Correct 1 ms 204 KB Output is correct
47 Correct 4 ms 332 KB Output is correct
48 Correct 0 ms 204 KB Output is correct
49 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 204 KB Output is correct
24 Correct 0 ms 204 KB Output is correct
25 Correct 0 ms 204 KB Output is correct
26 Correct 10 ms 424 KB Output is correct
27 Correct 8 ms 460 KB Output is correct
28 Correct 2 ms 332 KB Output is correct
29 Correct 1 ms 332 KB Output is correct
30 Correct 1 ms 204 KB Output is correct
31 Correct 29 ms 944 KB Output is correct
32 Correct 13 ms 592 KB Output is correct
33 Correct 11 ms 536 KB Output is correct
34 Correct 1 ms 204 KB Output is correct
35 Correct 0 ms 204 KB Output is correct
36 Correct 1 ms 332 KB Output is correct
37 Correct 7 ms 460 KB Output is correct
38 Correct 1 ms 332 KB Output is correct
39 Correct 0 ms 204 KB Output is correct
40 Correct 5 ms 332 KB Output is correct
41 Correct 1 ms 204 KB Output is correct
42 Correct 1 ms 204 KB Output is correct
43 Correct 1 ms 204 KB Output is correct
44 Correct 1 ms 204 KB Output is correct
45 Correct 1 ms 204 KB Output is correct
46 Correct 1 ms 204 KB Output is correct
47 Correct 4 ms 332 KB Output is correct
48 Correct 0 ms 204 KB Output is correct
49 Correct 1 ms 204 KB Output is correct
50 Correct 231 ms 2452 KB Output is correct
51 Correct 177 ms 1524 KB Output is correct
52 Correct 303 ms 2432 KB Output is correct
53 Correct 231 ms 2448 KB Output is correct
54 Correct 37 ms 696 KB Output is correct
55 Correct 1039 ms 8620 KB Output is correct
56 Correct 1054 ms 8568 KB Output is correct
57 Correct 485 ms 4484 KB Output is correct
58 Correct 0 ms 204 KB Output is correct
59 Correct 0 ms 204 KB Output is correct
60 Correct 5 ms 460 KB Output is correct
61 Correct 326 ms 4492 KB Output is correct
62 Correct 26 ms 592 KB Output is correct
63 Correct 7 ms 460 KB Output is correct
64 Correct 0 ms 204 KB Output is correct
65 Correct 97 ms 1456 KB Output is correct
66 Correct 1 ms 204 KB Output is correct
67 Correct 1 ms 204 KB Output is correct
68 Correct 0 ms 204 KB Output is correct
69 Correct 1 ms 332 KB Output is correct
70 Correct 15 ms 528 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 204 KB Output is correct
24 Correct 0 ms 204 KB Output is correct
25 Correct 0 ms 204 KB Output is correct
26 Correct 10 ms 424 KB Output is correct
27 Correct 8 ms 460 KB Output is correct
28 Correct 2 ms 332 KB Output is correct
29 Correct 1 ms 332 KB Output is correct
30 Correct 1 ms 204 KB Output is correct
31 Correct 29 ms 944 KB Output is correct
32 Correct 13 ms 592 KB Output is correct
33 Correct 11 ms 536 KB Output is correct
34 Correct 1 ms 204 KB Output is correct
35 Correct 0 ms 204 KB Output is correct
36 Correct 1 ms 332 KB Output is correct
37 Correct 7 ms 460 KB Output is correct
38 Correct 1 ms 332 KB Output is correct
39 Correct 0 ms 204 KB Output is correct
40 Correct 5 ms 332 KB Output is correct
41 Correct 1 ms 204 KB Output is correct
42 Correct 1 ms 204 KB Output is correct
43 Correct 1 ms 204 KB Output is correct
44 Correct 1 ms 204 KB Output is correct
45 Correct 1 ms 204 KB Output is correct
46 Correct 1 ms 204 KB Output is correct
47 Correct 4 ms 332 KB Output is correct
48 Correct 0 ms 204 KB Output is correct
49 Correct 1 ms 204 KB Output is correct
50 Correct 231 ms 2452 KB Output is correct
51 Correct 177 ms 1524 KB Output is correct
52 Correct 303 ms 2432 KB Output is correct
53 Correct 231 ms 2448 KB Output is correct
54 Correct 37 ms 696 KB Output is correct
55 Correct 1039 ms 8620 KB Output is correct
56 Correct 1054 ms 8568 KB Output is correct
57 Correct 485 ms 4484 KB Output is correct
58 Correct 0 ms 204 KB Output is correct
59 Correct 0 ms 204 KB Output is correct
60 Correct 5 ms 460 KB Output is correct
61 Correct 326 ms 4492 KB Output is correct
62 Correct 26 ms 592 KB Output is correct
63 Correct 7 ms 460 KB Output is correct
64 Correct 0 ms 204 KB Output is correct
65 Correct 97 ms 1456 KB Output is correct
66 Correct 1 ms 204 KB Output is correct
67 Correct 1 ms 204 KB Output is correct
68 Correct 0 ms 204 KB Output is correct
69 Correct 1 ms 332 KB Output is correct
70 Correct 15 ms 528 KB Output is correct
71 Execution timed out 5040 ms 8668 KB Time limit exceeded
72 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 204 KB Output is correct
24 Correct 0 ms 204 KB Output is correct
25 Correct 0 ms 204 KB Output is correct
26 Correct 10 ms 424 KB Output is correct
27 Correct 8 ms 460 KB Output is correct
28 Correct 2 ms 332 KB Output is correct
29 Correct 1 ms 332 KB Output is correct
30 Correct 1 ms 204 KB Output is correct
31 Correct 29 ms 944 KB Output is correct
32 Correct 13 ms 592 KB Output is correct
33 Correct 11 ms 536 KB Output is correct
34 Correct 1 ms 204 KB Output is correct
35 Correct 0 ms 204 KB Output is correct
36 Correct 1 ms 332 KB Output is correct
37 Correct 7 ms 460 KB Output is correct
38 Correct 1 ms 332 KB Output is correct
39 Correct 0 ms 204 KB Output is correct
40 Correct 5 ms 332 KB Output is correct
41 Correct 1 ms 204 KB Output is correct
42 Correct 1 ms 204 KB Output is correct
43 Correct 1 ms 204 KB Output is correct
44 Correct 1 ms 204 KB Output is correct
45 Correct 1 ms 204 KB Output is correct
46 Correct 1 ms 204 KB Output is correct
47 Correct 4 ms 332 KB Output is correct
48 Correct 0 ms 204 KB Output is correct
49 Correct 1 ms 204 KB Output is correct
50 Correct 231 ms 2452 KB Output is correct
51 Correct 177 ms 1524 KB Output is correct
52 Correct 303 ms 2432 KB Output is correct
53 Correct 231 ms 2448 KB Output is correct
54 Correct 37 ms 696 KB Output is correct
55 Correct 1039 ms 8620 KB Output is correct
56 Correct 1054 ms 8568 KB Output is correct
57 Correct 485 ms 4484 KB Output is correct
58 Correct 0 ms 204 KB Output is correct
59 Correct 0 ms 204 KB Output is correct
60 Correct 5 ms 460 KB Output is correct
61 Correct 326 ms 4492 KB Output is correct
62 Correct 26 ms 592 KB Output is correct
63 Correct 7 ms 460 KB Output is correct
64 Correct 0 ms 204 KB Output is correct
65 Correct 97 ms 1456 KB Output is correct
66 Correct 1 ms 204 KB Output is correct
67 Correct 1 ms 204 KB Output is correct
68 Correct 0 ms 204 KB Output is correct
69 Correct 1 ms 332 KB Output is correct
70 Correct 15 ms 528 KB Output is correct
71 Execution timed out 5040 ms 8668 KB Time limit exceeded
72 Halted 0 ms 0 KB -