답안 #1068288

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1068288 2024-08-21T09:06:37 Z cpdreamer Toys (CEOI18_toy) C++14
59 / 100
5000 ms 72276 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <utility>
#define V vector
#define F first
#define S second
#define P pair
#define pb push_back
#define all(v) v.begin(),v.end()
typedef long long ll;
using namespace __gnu_pbds;
using namespace std;
typedef tree<int,null_type,less<int>,rb_tree_tag,
        tree_order_statistics_node_update> indexed_set;
static int called = 0;const long long MOD = 1e9+7; // 1e9 + 7

void file(){
    freopen("input.txt.txt","r",stdin);
    freopen("output.txt.txt","w",stdout);
}

void solve() {
    int n;
    cin>>n;
    if(n==1){
        cout<<1<<endl;
        cout<<0<<endl;
        return;
    }
    V<int>factor;
    bool prime[n+1];
    prime[1]=false;
    for(int i=2;i<=n;i++){
        prime[i]=true;
        for(int j=2;j<i;j++){
            if(i%j==0) {
                prime[i] = false;
                break;
            }
        }
    }
    V<int>primes;
    for(int i=2;i<=n;++i){
        if(prime[i])
            primes.pb(i);
    }
    int p=0;
    while(n>1){
        if(n%primes[p]==0){
            n/=primes[p];
            factor.pb(primes[p]);
        }
        else
            p++;
    }
    set<V<int>>st;
    st.insert({factor[0]});
    for(int i=1;i<factor.size();i++) {
        set<V<int>>st1;
        for (auto &u: st) {
            for (int j=0;j<u.size();j++) {
                V<int>v=u;
                v[j]*=factor[i];
                sort(all(v));
                st1.insert(v);
            }
            V<int>v=u;
            v.pb(factor[i]);
            sort(all(v));
            st1.insert(v);
        }
        st=st1;
    }
    V<int>ans;
    for(auto u:st) {
        int c = 0;
        for (auto x: u) {
            c += x - 1;
        }
        ans.pb(c);
    }
    sort(all(ans));
    auto it=unique(all(ans));
    ans.resize(distance(ans.begin(),it));
    cout<<ans.size()<<endl;
    for(auto u:ans)
        cout<<u<<" ";
    cout<<endl;
}
int main(){
    //file();
    solve();
}

Compilation message

toy.cpp: In function 'void solve()':
toy.cpp:58:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |     for(int i=1;i<factor.size();i++) {
      |                 ~^~~~~~~~~~~~~~
toy.cpp:61:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   61 |             for (int j=0;j<u.size();j++) {
      |                          ~^~~~~~~~~
toy.cpp: In function 'void file()':
toy.cpp:18:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |     freopen("input.txt.txt","r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
toy.cpp:19:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |     freopen("output.txt.txt","w",stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
toy.cpp: At global scope:
toy.cpp:15:12: warning: 'called' defined but not used [-Wunused-variable]
   15 | static int called = 0;const long long MOD = 1e9+7; // 1e9 + 7
      |            ^~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 432 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 432 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 344 KB Output is correct
26 Correct 8 ms 348 KB Output is correct
27 Correct 4 ms 484 KB Output is correct
28 Correct 2 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 10 ms 348 KB Output is correct
32 Correct 7 ms 360 KB Output is correct
33 Correct 6 ms 348 KB Output is correct
34 Correct 12 ms 436 KB Output is correct
35 Correct 11 ms 348 KB Output is correct
36 Correct 8 ms 348 KB Output is correct
37 Correct 8 ms 348 KB Output is correct
38 Correct 12 ms 440 KB Output is correct
39 Correct 12 ms 348 KB Output is correct
40 Correct 10 ms 440 KB Output is correct
41 Correct 12 ms 440 KB Output is correct
42 Correct 11 ms 348 KB Output is correct
43 Correct 10 ms 440 KB Output is correct
44 Correct 12 ms 348 KB Output is correct
45 Correct 12 ms 348 KB Output is correct
46 Correct 12 ms 348 KB Output is correct
47 Correct 12 ms 348 KB Output is correct
48 Correct 11 ms 348 KB Output is correct
49 Correct 12 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 432 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 344 KB Output is correct
26 Correct 8 ms 348 KB Output is correct
27 Correct 4 ms 484 KB Output is correct
28 Correct 2 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 10 ms 348 KB Output is correct
32 Correct 7 ms 360 KB Output is correct
33 Correct 6 ms 348 KB Output is correct
34 Correct 12 ms 436 KB Output is correct
35 Correct 11 ms 348 KB Output is correct
36 Correct 8 ms 348 KB Output is correct
37 Correct 8 ms 348 KB Output is correct
38 Correct 12 ms 440 KB Output is correct
39 Correct 12 ms 348 KB Output is correct
40 Correct 10 ms 440 KB Output is correct
41 Correct 12 ms 440 KB Output is correct
42 Correct 11 ms 348 KB Output is correct
43 Correct 10 ms 440 KB Output is correct
44 Correct 12 ms 348 KB Output is correct
45 Correct 12 ms 348 KB Output is correct
46 Correct 12 ms 348 KB Output is correct
47 Correct 12 ms 348 KB Output is correct
48 Correct 11 ms 348 KB Output is correct
49 Correct 12 ms 348 KB Output is correct
50 Correct 626 ms 848 KB Output is correct
51 Correct 290 ms 716 KB Output is correct
52 Correct 242 ms 728 KB Output is correct
53 Correct 200 ms 592 KB Output is correct
54 Correct 78 ms 596 KB Output is correct
55 Correct 738 ms 1108 KB Output is correct
56 Correct 591 ms 1000 KB Output is correct
57 Correct 522 ms 1008 KB Output is correct
58 Correct 890 ms 504 KB Output is correct
59 Correct 846 ms 504 KB Output is correct
60 Correct 397 ms 472 KB Output is correct
61 Correct 782 ms 752 KB Output is correct
62 Correct 75 ms 436 KB Output is correct
63 Correct 886 ms 520 KB Output is correct
64 Correct 887 ms 500 KB Output is correct
65 Correct 727 ms 592 KB Output is correct
66 Correct 891 ms 500 KB Output is correct
67 Correct 891 ms 508 KB Output is correct
68 Correct 890 ms 592 KB Output is correct
69 Correct 892 ms 500 KB Output is correct
70 Correct 727 ms 492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 432 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 344 KB Output is correct
26 Correct 8 ms 348 KB Output is correct
27 Correct 4 ms 484 KB Output is correct
28 Correct 2 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 10 ms 348 KB Output is correct
32 Correct 7 ms 360 KB Output is correct
33 Correct 6 ms 348 KB Output is correct
34 Correct 12 ms 436 KB Output is correct
35 Correct 11 ms 348 KB Output is correct
36 Correct 8 ms 348 KB Output is correct
37 Correct 8 ms 348 KB Output is correct
38 Correct 12 ms 440 KB Output is correct
39 Correct 12 ms 348 KB Output is correct
40 Correct 10 ms 440 KB Output is correct
41 Correct 12 ms 440 KB Output is correct
42 Correct 11 ms 348 KB Output is correct
43 Correct 10 ms 440 KB Output is correct
44 Correct 12 ms 348 KB Output is correct
45 Correct 12 ms 348 KB Output is correct
46 Correct 12 ms 348 KB Output is correct
47 Correct 12 ms 348 KB Output is correct
48 Correct 11 ms 348 KB Output is correct
49 Correct 12 ms 348 KB Output is correct
50 Correct 626 ms 848 KB Output is correct
51 Correct 290 ms 716 KB Output is correct
52 Correct 242 ms 728 KB Output is correct
53 Correct 200 ms 592 KB Output is correct
54 Correct 78 ms 596 KB Output is correct
55 Correct 738 ms 1108 KB Output is correct
56 Correct 591 ms 1000 KB Output is correct
57 Correct 522 ms 1008 KB Output is correct
58 Correct 890 ms 504 KB Output is correct
59 Correct 846 ms 504 KB Output is correct
60 Correct 397 ms 472 KB Output is correct
61 Correct 782 ms 752 KB Output is correct
62 Correct 75 ms 436 KB Output is correct
63 Correct 886 ms 520 KB Output is correct
64 Correct 887 ms 500 KB Output is correct
65 Correct 727 ms 592 KB Output is correct
66 Correct 891 ms 500 KB Output is correct
67 Correct 891 ms 508 KB Output is correct
68 Correct 890 ms 592 KB Output is correct
69 Correct 892 ms 500 KB Output is correct
70 Correct 727 ms 492 KB Output is correct
71 Execution timed out 5018 ms 72276 KB Time limit exceeded
72 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 432 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 344 KB Output is correct
26 Correct 8 ms 348 KB Output is correct
27 Correct 4 ms 484 KB Output is correct
28 Correct 2 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 10 ms 348 KB Output is correct
32 Correct 7 ms 360 KB Output is correct
33 Correct 6 ms 348 KB Output is correct
34 Correct 12 ms 436 KB Output is correct
35 Correct 11 ms 348 KB Output is correct
36 Correct 8 ms 348 KB Output is correct
37 Correct 8 ms 348 KB Output is correct
38 Correct 12 ms 440 KB Output is correct
39 Correct 12 ms 348 KB Output is correct
40 Correct 10 ms 440 KB Output is correct
41 Correct 12 ms 440 KB Output is correct
42 Correct 11 ms 348 KB Output is correct
43 Correct 10 ms 440 KB Output is correct
44 Correct 12 ms 348 KB Output is correct
45 Correct 12 ms 348 KB Output is correct
46 Correct 12 ms 348 KB Output is correct
47 Correct 12 ms 348 KB Output is correct
48 Correct 11 ms 348 KB Output is correct
49 Correct 12 ms 348 KB Output is correct
50 Correct 626 ms 848 KB Output is correct
51 Correct 290 ms 716 KB Output is correct
52 Correct 242 ms 728 KB Output is correct
53 Correct 200 ms 592 KB Output is correct
54 Correct 78 ms 596 KB Output is correct
55 Correct 738 ms 1108 KB Output is correct
56 Correct 591 ms 1000 KB Output is correct
57 Correct 522 ms 1008 KB Output is correct
58 Correct 890 ms 504 KB Output is correct
59 Correct 846 ms 504 KB Output is correct
60 Correct 397 ms 472 KB Output is correct
61 Correct 782 ms 752 KB Output is correct
62 Correct 75 ms 436 KB Output is correct
63 Correct 886 ms 520 KB Output is correct
64 Correct 887 ms 500 KB Output is correct
65 Correct 727 ms 592 KB Output is correct
66 Correct 891 ms 500 KB Output is correct
67 Correct 891 ms 508 KB Output is correct
68 Correct 890 ms 592 KB Output is correct
69 Correct 892 ms 500 KB Output is correct
70 Correct 727 ms 492 KB Output is correct
71 Execution timed out 5018 ms 72276 KB Time limit exceeded
72 Halted 0 ms 0 KB -