Submission #70889

# Submission time Handle Problem Language Result Execution time Memory
70889 2018-08-23T15:36:55 Z georgerapeanu Toys (CEOI18_toy) C++11
100 / 100
1798 ms 110288 KB
#include <cstdio>
#include <set>
#include <algorithm>
#include <vector>

using namespace std;

int N;

vector<int> divisors;
vector< vector<int> > sums;
vector<int> ans;

int main() {

    fscanf(stdin,"%d",&N);
    for(int d = 2;1LL * d * d <= N;d++){
         if(N % d == 0){
            divisors.push_back(d);
            if(d * d != N){
               divisors.push_back(N / d);
            }
         }
    }

    divisors.push_back(N);

    sort(divisors.begin(),divisors.end());

    sums.resize(divisors.size());

    for(int i = 0;i < (int)divisors.size();i++){
       sums[i].push_back(divisors[i] - 1);
       int st = 0;
       for(int j = i - 1;j >= 0;j--){
          while(st < i - 1 && 1LL * divisors[j] * divisors[st] < divisors[i]){
             st++;
          }

          if(divisors[j] * divisors[st] != divisors[i]){
            continue;
          }

          for(auto it:sums[st]){
               sums[i].push_back(it + divisors[j] - 1);
          }
       }
       sort(sums[i].begin(),sums[i].end());
       sums[i].resize(unique(sums[i].begin(),sums[i].end()) - sums[i].begin());
    }

   fprintf(stdout,"%d\n",(int)sums.back().size());

    for(auto it:sums.back()){
       fprintf(stdout,"%d ",it);
    }

    return 0;
}

Compilation message

toy.cpp: In function 'int main()':
toy.cpp:16:11: warning: ignoring return value of 'int fscanf(FILE*, const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     fscanf(stdin,"%d",&N);
     ~~~~~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 3 ms 488 KB Output is correct
3 Correct 2 ms 532 KB Output is correct
4 Correct 3 ms 532 KB Output is correct
5 Correct 4 ms 552 KB Output is correct
6 Correct 2 ms 568 KB Output is correct
7 Correct 2 ms 568 KB Output is correct
8 Correct 2 ms 568 KB Output is correct
9 Correct 3 ms 568 KB Output is correct
10 Correct 2 ms 568 KB Output is correct
11 Correct 2 ms 568 KB Output is correct
12 Correct 2 ms 568 KB Output is correct
13 Correct 2 ms 568 KB Output is correct
14 Correct 2 ms 568 KB Output is correct
15 Correct 3 ms 568 KB Output is correct
16 Correct 3 ms 568 KB Output is correct
17 Correct 4 ms 568 KB Output is correct
18 Correct 2 ms 568 KB Output is correct
19 Correct 2 ms 568 KB Output is correct
20 Correct 3 ms 568 KB Output is correct
21 Correct 3 ms 568 KB Output is correct
22 Correct 3 ms 568 KB Output is correct
23 Correct 3 ms 568 KB Output is correct
24 Correct 2 ms 568 KB Output is correct
25 Correct 2 ms 568 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 3 ms 488 KB Output is correct
3 Correct 2 ms 532 KB Output is correct
4 Correct 3 ms 532 KB Output is correct
5 Correct 4 ms 552 KB Output is correct
6 Correct 2 ms 568 KB Output is correct
7 Correct 2 ms 568 KB Output is correct
8 Correct 2 ms 568 KB Output is correct
9 Correct 3 ms 568 KB Output is correct
10 Correct 2 ms 568 KB Output is correct
11 Correct 2 ms 568 KB Output is correct
12 Correct 2 ms 568 KB Output is correct
13 Correct 2 ms 568 KB Output is correct
14 Correct 2 ms 568 KB Output is correct
15 Correct 3 ms 568 KB Output is correct
16 Correct 3 ms 568 KB Output is correct
17 Correct 4 ms 568 KB Output is correct
18 Correct 2 ms 568 KB Output is correct
19 Correct 2 ms 568 KB Output is correct
20 Correct 3 ms 568 KB Output is correct
21 Correct 3 ms 568 KB Output is correct
22 Correct 3 ms 568 KB Output is correct
23 Correct 3 ms 568 KB Output is correct
24 Correct 2 ms 568 KB Output is correct
25 Correct 2 ms 568 KB Output is correct
26 Correct 3 ms 568 KB Output is correct
27 Correct 3 ms 568 KB Output is correct
28 Correct 3 ms 568 KB Output is correct
29 Correct 3 ms 568 KB Output is correct
30 Correct 2 ms 636 KB Output is correct
31 Correct 4 ms 636 KB Output is correct
32 Correct 3 ms 636 KB Output is correct
33 Correct 3 ms 636 KB Output is correct
34 Correct 2 ms 636 KB Output is correct
35 Correct 3 ms 636 KB Output is correct
36 Correct 3 ms 636 KB Output is correct
37 Correct 4 ms 636 KB Output is correct
38 Correct 2 ms 636 KB Output is correct
39 Correct 2 ms 636 KB Output is correct
40 Correct 2 ms 636 KB Output is correct
41 Correct 3 ms 636 KB Output is correct
42 Correct 3 ms 636 KB Output is correct
43 Correct 4 ms 636 KB Output is correct
44 Correct 3 ms 636 KB Output is correct
45 Correct 3 ms 636 KB Output is correct
46 Correct 2 ms 636 KB Output is correct
47 Correct 3 ms 636 KB Output is correct
48 Correct 3 ms 636 KB Output is correct
49 Correct 4 ms 636 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 3 ms 488 KB Output is correct
3 Correct 2 ms 532 KB Output is correct
4 Correct 3 ms 532 KB Output is correct
5 Correct 4 ms 552 KB Output is correct
6 Correct 2 ms 568 KB Output is correct
7 Correct 2 ms 568 KB Output is correct
8 Correct 2 ms 568 KB Output is correct
9 Correct 3 ms 568 KB Output is correct
10 Correct 2 ms 568 KB Output is correct
11 Correct 2 ms 568 KB Output is correct
12 Correct 2 ms 568 KB Output is correct
13 Correct 2 ms 568 KB Output is correct
14 Correct 2 ms 568 KB Output is correct
15 Correct 3 ms 568 KB Output is correct
16 Correct 3 ms 568 KB Output is correct
17 Correct 4 ms 568 KB Output is correct
18 Correct 2 ms 568 KB Output is correct
19 Correct 2 ms 568 KB Output is correct
20 Correct 3 ms 568 KB Output is correct
21 Correct 3 ms 568 KB Output is correct
22 Correct 3 ms 568 KB Output is correct
23 Correct 3 ms 568 KB Output is correct
24 Correct 2 ms 568 KB Output is correct
25 Correct 2 ms 568 KB Output is correct
26 Correct 3 ms 568 KB Output is correct
27 Correct 3 ms 568 KB Output is correct
28 Correct 3 ms 568 KB Output is correct
29 Correct 3 ms 568 KB Output is correct
30 Correct 2 ms 636 KB Output is correct
31 Correct 4 ms 636 KB Output is correct
32 Correct 3 ms 636 KB Output is correct
33 Correct 3 ms 636 KB Output is correct
34 Correct 2 ms 636 KB Output is correct
35 Correct 3 ms 636 KB Output is correct
36 Correct 3 ms 636 KB Output is correct
37 Correct 4 ms 636 KB Output is correct
38 Correct 2 ms 636 KB Output is correct
39 Correct 2 ms 636 KB Output is correct
40 Correct 2 ms 636 KB Output is correct
41 Correct 3 ms 636 KB Output is correct
42 Correct 3 ms 636 KB Output is correct
43 Correct 4 ms 636 KB Output is correct
44 Correct 3 ms 636 KB Output is correct
45 Correct 3 ms 636 KB Output is correct
46 Correct 2 ms 636 KB Output is correct
47 Correct 3 ms 636 KB Output is correct
48 Correct 3 ms 636 KB Output is correct
49 Correct 4 ms 636 KB Output is correct
50 Correct 5 ms 764 KB Output is correct
51 Correct 4 ms 764 KB Output is correct
52 Correct 4 ms 764 KB Output is correct
53 Correct 4 ms 764 KB Output is correct
54 Correct 3 ms 764 KB Output is correct
55 Correct 6 ms 892 KB Output is correct
56 Correct 5 ms 892 KB Output is correct
57 Correct 4 ms 892 KB Output is correct
58 Correct 2 ms 892 KB Output is correct
59 Correct 2 ms 892 KB Output is correct
60 Correct 3 ms 892 KB Output is correct
61 Correct 4 ms 892 KB Output is correct
62 Correct 3 ms 892 KB Output is correct
63 Correct 4 ms 892 KB Output is correct
64 Correct 3 ms 892 KB Output is correct
65 Correct 3 ms 892 KB Output is correct
66 Correct 2 ms 892 KB Output is correct
67 Correct 3 ms 892 KB Output is correct
68 Correct 3 ms 892 KB Output is correct
69 Correct 4 ms 892 KB Output is correct
70 Correct 4 ms 892 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 3 ms 488 KB Output is correct
3 Correct 2 ms 532 KB Output is correct
4 Correct 3 ms 532 KB Output is correct
5 Correct 4 ms 552 KB Output is correct
6 Correct 2 ms 568 KB Output is correct
7 Correct 2 ms 568 KB Output is correct
8 Correct 2 ms 568 KB Output is correct
9 Correct 3 ms 568 KB Output is correct
10 Correct 2 ms 568 KB Output is correct
11 Correct 2 ms 568 KB Output is correct
12 Correct 2 ms 568 KB Output is correct
13 Correct 2 ms 568 KB Output is correct
14 Correct 2 ms 568 KB Output is correct
15 Correct 3 ms 568 KB Output is correct
16 Correct 3 ms 568 KB Output is correct
17 Correct 4 ms 568 KB Output is correct
18 Correct 2 ms 568 KB Output is correct
19 Correct 2 ms 568 KB Output is correct
20 Correct 3 ms 568 KB Output is correct
21 Correct 3 ms 568 KB Output is correct
22 Correct 3 ms 568 KB Output is correct
23 Correct 3 ms 568 KB Output is correct
24 Correct 2 ms 568 KB Output is correct
25 Correct 2 ms 568 KB Output is correct
26 Correct 3 ms 568 KB Output is correct
27 Correct 3 ms 568 KB Output is correct
28 Correct 3 ms 568 KB Output is correct
29 Correct 3 ms 568 KB Output is correct
30 Correct 2 ms 636 KB Output is correct
31 Correct 4 ms 636 KB Output is correct
32 Correct 3 ms 636 KB Output is correct
33 Correct 3 ms 636 KB Output is correct
34 Correct 2 ms 636 KB Output is correct
35 Correct 3 ms 636 KB Output is correct
36 Correct 3 ms 636 KB Output is correct
37 Correct 4 ms 636 KB Output is correct
38 Correct 2 ms 636 KB Output is correct
39 Correct 2 ms 636 KB Output is correct
40 Correct 2 ms 636 KB Output is correct
41 Correct 3 ms 636 KB Output is correct
42 Correct 3 ms 636 KB Output is correct
43 Correct 4 ms 636 KB Output is correct
44 Correct 3 ms 636 KB Output is correct
45 Correct 3 ms 636 KB Output is correct
46 Correct 2 ms 636 KB Output is correct
47 Correct 3 ms 636 KB Output is correct
48 Correct 3 ms 636 KB Output is correct
49 Correct 4 ms 636 KB Output is correct
50 Correct 5 ms 764 KB Output is correct
51 Correct 4 ms 764 KB Output is correct
52 Correct 4 ms 764 KB Output is correct
53 Correct 4 ms 764 KB Output is correct
54 Correct 3 ms 764 KB Output is correct
55 Correct 6 ms 892 KB Output is correct
56 Correct 5 ms 892 KB Output is correct
57 Correct 4 ms 892 KB Output is correct
58 Correct 2 ms 892 KB Output is correct
59 Correct 2 ms 892 KB Output is correct
60 Correct 3 ms 892 KB Output is correct
61 Correct 4 ms 892 KB Output is correct
62 Correct 3 ms 892 KB Output is correct
63 Correct 4 ms 892 KB Output is correct
64 Correct 3 ms 892 KB Output is correct
65 Correct 3 ms 892 KB Output is correct
66 Correct 2 ms 892 KB Output is correct
67 Correct 3 ms 892 KB Output is correct
68 Correct 3 ms 892 KB Output is correct
69 Correct 4 ms 892 KB Output is correct
70 Correct 4 ms 892 KB Output is correct
71 Correct 268 ms 18092 KB Output is correct
72 Correct 178 ms 18092 KB Output is correct
73 Correct 235 ms 18092 KB Output is correct
74 Correct 172 ms 18092 KB Output is correct
75 Correct 157 ms 18092 KB Output is correct
76 Correct 427 ms 27424 KB Output is correct
77 Correct 376 ms 27424 KB Output is correct
78 Correct 333 ms 27424 KB Output is correct
79 Correct 328 ms 27424 KB Output is correct
80 Correct 3 ms 27424 KB Output is correct
81 Correct 3 ms 27424 KB Output is correct
82 Correct 4 ms 27424 KB Output is correct
83 Correct 35 ms 27424 KB Output is correct
84 Correct 48 ms 27424 KB Output is correct
85 Correct 12 ms 27424 KB Output is correct
86 Correct 3 ms 27424 KB Output is correct
87 Correct 63 ms 27424 KB Output is correct
88 Correct 2 ms 27424 KB Output is correct
89 Correct 3 ms 27424 KB Output is correct
90 Correct 2 ms 27424 KB Output is correct
91 Correct 15 ms 27424 KB Output is correct
92 Correct 59 ms 27424 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 3 ms 488 KB Output is correct
3 Correct 2 ms 532 KB Output is correct
4 Correct 3 ms 532 KB Output is correct
5 Correct 4 ms 552 KB Output is correct
6 Correct 2 ms 568 KB Output is correct
7 Correct 2 ms 568 KB Output is correct
8 Correct 2 ms 568 KB Output is correct
9 Correct 3 ms 568 KB Output is correct
10 Correct 2 ms 568 KB Output is correct
11 Correct 2 ms 568 KB Output is correct
12 Correct 2 ms 568 KB Output is correct
13 Correct 2 ms 568 KB Output is correct
14 Correct 2 ms 568 KB Output is correct
15 Correct 3 ms 568 KB Output is correct
16 Correct 3 ms 568 KB Output is correct
17 Correct 4 ms 568 KB Output is correct
18 Correct 2 ms 568 KB Output is correct
19 Correct 2 ms 568 KB Output is correct
20 Correct 3 ms 568 KB Output is correct
21 Correct 3 ms 568 KB Output is correct
22 Correct 3 ms 568 KB Output is correct
23 Correct 3 ms 568 KB Output is correct
24 Correct 2 ms 568 KB Output is correct
25 Correct 2 ms 568 KB Output is correct
26 Correct 3 ms 568 KB Output is correct
27 Correct 3 ms 568 KB Output is correct
28 Correct 3 ms 568 KB Output is correct
29 Correct 3 ms 568 KB Output is correct
30 Correct 2 ms 636 KB Output is correct
31 Correct 4 ms 636 KB Output is correct
32 Correct 3 ms 636 KB Output is correct
33 Correct 3 ms 636 KB Output is correct
34 Correct 2 ms 636 KB Output is correct
35 Correct 3 ms 636 KB Output is correct
36 Correct 3 ms 636 KB Output is correct
37 Correct 4 ms 636 KB Output is correct
38 Correct 2 ms 636 KB Output is correct
39 Correct 2 ms 636 KB Output is correct
40 Correct 2 ms 636 KB Output is correct
41 Correct 3 ms 636 KB Output is correct
42 Correct 3 ms 636 KB Output is correct
43 Correct 4 ms 636 KB Output is correct
44 Correct 3 ms 636 KB Output is correct
45 Correct 3 ms 636 KB Output is correct
46 Correct 2 ms 636 KB Output is correct
47 Correct 3 ms 636 KB Output is correct
48 Correct 3 ms 636 KB Output is correct
49 Correct 4 ms 636 KB Output is correct
50 Correct 5 ms 764 KB Output is correct
51 Correct 4 ms 764 KB Output is correct
52 Correct 4 ms 764 KB Output is correct
53 Correct 4 ms 764 KB Output is correct
54 Correct 3 ms 764 KB Output is correct
55 Correct 6 ms 892 KB Output is correct
56 Correct 5 ms 892 KB Output is correct
57 Correct 4 ms 892 KB Output is correct
58 Correct 2 ms 892 KB Output is correct
59 Correct 2 ms 892 KB Output is correct
60 Correct 3 ms 892 KB Output is correct
61 Correct 4 ms 892 KB Output is correct
62 Correct 3 ms 892 KB Output is correct
63 Correct 4 ms 892 KB Output is correct
64 Correct 3 ms 892 KB Output is correct
65 Correct 3 ms 892 KB Output is correct
66 Correct 2 ms 892 KB Output is correct
67 Correct 3 ms 892 KB Output is correct
68 Correct 3 ms 892 KB Output is correct
69 Correct 4 ms 892 KB Output is correct
70 Correct 4 ms 892 KB Output is correct
71 Correct 268 ms 18092 KB Output is correct
72 Correct 178 ms 18092 KB Output is correct
73 Correct 235 ms 18092 KB Output is correct
74 Correct 172 ms 18092 KB Output is correct
75 Correct 157 ms 18092 KB Output is correct
76 Correct 427 ms 27424 KB Output is correct
77 Correct 376 ms 27424 KB Output is correct
78 Correct 333 ms 27424 KB Output is correct
79 Correct 328 ms 27424 KB Output is correct
80 Correct 3 ms 27424 KB Output is correct
81 Correct 3 ms 27424 KB Output is correct
82 Correct 4 ms 27424 KB Output is correct
83 Correct 35 ms 27424 KB Output is correct
84 Correct 48 ms 27424 KB Output is correct
85 Correct 12 ms 27424 KB Output is correct
86 Correct 3 ms 27424 KB Output is correct
87 Correct 63 ms 27424 KB Output is correct
88 Correct 2 ms 27424 KB Output is correct
89 Correct 3 ms 27424 KB Output is correct
90 Correct 2 ms 27424 KB Output is correct
91 Correct 15 ms 27424 KB Output is correct
92 Correct 59 ms 27424 KB Output is correct
93 Correct 1436 ms 90776 KB Output is correct
94 Correct 786 ms 90776 KB Output is correct
95 Correct 915 ms 90776 KB Output is correct
96 Correct 824 ms 90776 KB Output is correct
97 Correct 758 ms 90776 KB Output is correct
98 Correct 1734 ms 104496 KB Output is correct
99 Correct 1798 ms 110288 KB Output is correct
100 Correct 1597 ms 110288 KB Output is correct
101 Correct 1495 ms 110288 KB Output is correct
102 Correct 1336 ms 110288 KB Output is correct
103 Correct 1006 ms 110288 KB Output is correct
104 Correct 3 ms 110288 KB Output is correct
105 Correct 3 ms 110288 KB Output is correct
106 Correct 6 ms 110288 KB Output is correct
107 Correct 110 ms 110288 KB Output is correct
108 Correct 279 ms 110288 KB Output is correct
109 Correct 26 ms 110288 KB Output is correct
110 Correct 3 ms 110288 KB Output is correct
111 Correct 131 ms 110288 KB Output is correct
112 Correct 4 ms 110288 KB Output is correct
113 Correct 2 ms 110288 KB Output is correct
114 Correct 6 ms 110288 KB Output is correct
115 Correct 2 ms 110288 KB Output is correct
116 Correct 12 ms 110288 KB Output is correct
117 Correct 273 ms 110288 KB Output is correct