답안 #72621

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
72621 2018-08-26T12:05:43 Z istlemin Toys (CEOI18_toy) C++14
59 / 100
5000 ms 56572 KB
#include<bits/stdc++.h>

using namespace std;

#define rep(i,a,b) for(int i = a; i<int(b);++i)
#define re(i,a,b) for(i = a; i<int(b);++i)
#define all(v) v.begin(),v.end()
#define sz(v) v.size()
#define trav(a,c) for(auto a: c)

typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pii;

map<ll,ll> getFactors(ll x){
	map<ll,ll> res;
    rep(i,2,sqrt(x)+1){
		//cout<<i<<" "<<x<<endl;
        if(x%i==0){
			x/=i;
			res[i]++;
			i = 1;
        }
    }
    res[x]++;
    return res;
}

set<ll> ans;
map<pair<vi,ll>,bool> seen;
vi f;

void getAns(vi facs,ll sum){
    if(seen[{facs,sum}]) return;
    seen[{facs,sum}] = true;
    bool all0 = true;
	rep(i,0,facs.size()) {
		all0 &= (facs[i]==0);
        //cout<<facs[i]<<" ";
	}
	//cout<<endl;
	//cout<<sum<<": "<<endl;
	if(all0){
		ans.insert(sum);
		return;
	}

    vi l(facs.size());
    re(l[0],0,facs[0]+1)
    re(l[1],0,facs[1]+1)
    re(l[2],0,facs[2]+1)
    re(l[3],0,facs[3]+1)
    re(l[4],0,facs[4]+1)
    re(l[5],0,facs[5]+1)
    re(l[6],0,facs[6]+1)
    re(l[7],0,facs[7]+1)
    re(l[8],0,facs[8]+1)
    re(l[9],0,facs[9]+1)
    re(l[10],0,facs[10]+1)
    re(l[11],0,facs[11]+1){
        ll add = 1;
        rep(i,0,facs.size()) add *= pow(f[i],facs[i]-l[i]);
        getAns(l,sum+add-1);
    }
}

int main(){
	cin.sync_with_stdio(false);
	ll n;
	cin>>n;

    vi facs;
    trav(fi,getFactors(n)){
        facs.push_back(fi.second);
        f.push_back(fi.first);
        //cout<<f.first<<" "<<f.second<<endl;
    }
    //cout<<endl;

    while(facs.size()<12) {
		facs.push_back(0);
		f.push_back(1);
	}
    getAns(facs,0);
    cout<<ans.size()<<endl;
    trav(a,ans){
		cout<<a<<" ";
    }
    cout<<endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 356 KB Output is correct
3 Correct 3 ms 432 KB Output is correct
4 Correct 3 ms 468 KB Output is correct
5 Correct 3 ms 596 KB Output is correct
6 Correct 3 ms 596 KB Output is correct
7 Correct 2 ms 596 KB Output is correct
8 Correct 2 ms 596 KB Output is correct
9 Correct 2 ms 596 KB Output is correct
10 Correct 2 ms 660 KB Output is correct
11 Correct 2 ms 660 KB Output is correct
12 Correct 3 ms 660 KB Output is correct
13 Correct 3 ms 692 KB Output is correct
14 Correct 3 ms 692 KB Output is correct
15 Correct 2 ms 692 KB Output is correct
16 Correct 2 ms 692 KB Output is correct
17 Correct 4 ms 692 KB Output is correct
18 Correct 3 ms 692 KB Output is correct
19 Correct 2 ms 692 KB Output is correct
20 Correct 2 ms 692 KB Output is correct
21 Correct 2 ms 692 KB Output is correct
22 Correct 2 ms 692 KB Output is correct
23 Correct 3 ms 692 KB Output is correct
24 Correct 3 ms 692 KB Output is correct
25 Correct 3 ms 716 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 356 KB Output is correct
3 Correct 3 ms 432 KB Output is correct
4 Correct 3 ms 468 KB Output is correct
5 Correct 3 ms 596 KB Output is correct
6 Correct 3 ms 596 KB Output is correct
7 Correct 2 ms 596 KB Output is correct
8 Correct 2 ms 596 KB Output is correct
9 Correct 2 ms 596 KB Output is correct
10 Correct 2 ms 660 KB Output is correct
11 Correct 2 ms 660 KB Output is correct
12 Correct 3 ms 660 KB Output is correct
13 Correct 3 ms 692 KB Output is correct
14 Correct 3 ms 692 KB Output is correct
15 Correct 2 ms 692 KB Output is correct
16 Correct 2 ms 692 KB Output is correct
17 Correct 4 ms 692 KB Output is correct
18 Correct 3 ms 692 KB Output is correct
19 Correct 2 ms 692 KB Output is correct
20 Correct 2 ms 692 KB Output is correct
21 Correct 2 ms 692 KB Output is correct
22 Correct 2 ms 692 KB Output is correct
23 Correct 3 ms 692 KB Output is correct
24 Correct 3 ms 692 KB Output is correct
25 Correct 3 ms 716 KB Output is correct
26 Correct 9 ms 844 KB Output is correct
27 Correct 8 ms 844 KB Output is correct
28 Correct 5 ms 844 KB Output is correct
29 Correct 4 ms 844 KB Output is correct
30 Correct 4 ms 844 KB Output is correct
31 Correct 10 ms 876 KB Output is correct
32 Correct 8 ms 1004 KB Output is correct
33 Correct 8 ms 1004 KB Output is correct
34 Correct 2 ms 1004 KB Output is correct
35 Correct 2 ms 1004 KB Output is correct
36 Correct 3 ms 1004 KB Output is correct
37 Correct 6 ms 1004 KB Output is correct
38 Correct 3 ms 1004 KB Output is correct
39 Correct 2 ms 1004 KB Output is correct
40 Correct 5 ms 1004 KB Output is correct
41 Correct 2 ms 1004 KB Output is correct
42 Correct 2 ms 1004 KB Output is correct
43 Correct 2 ms 1004 KB Output is correct
44 Correct 2 ms 1004 KB Output is correct
45 Correct 3 ms 1004 KB Output is correct
46 Correct 3 ms 1004 KB Output is correct
47 Correct 6 ms 1004 KB Output is correct
48 Correct 2 ms 1004 KB Output is correct
49 Correct 3 ms 1004 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 356 KB Output is correct
3 Correct 3 ms 432 KB Output is correct
4 Correct 3 ms 468 KB Output is correct
5 Correct 3 ms 596 KB Output is correct
6 Correct 3 ms 596 KB Output is correct
7 Correct 2 ms 596 KB Output is correct
8 Correct 2 ms 596 KB Output is correct
9 Correct 2 ms 596 KB Output is correct
10 Correct 2 ms 660 KB Output is correct
11 Correct 2 ms 660 KB Output is correct
12 Correct 3 ms 660 KB Output is correct
13 Correct 3 ms 692 KB Output is correct
14 Correct 3 ms 692 KB Output is correct
15 Correct 2 ms 692 KB Output is correct
16 Correct 2 ms 692 KB Output is correct
17 Correct 4 ms 692 KB Output is correct
18 Correct 3 ms 692 KB Output is correct
19 Correct 2 ms 692 KB Output is correct
20 Correct 2 ms 692 KB Output is correct
21 Correct 2 ms 692 KB Output is correct
22 Correct 2 ms 692 KB Output is correct
23 Correct 3 ms 692 KB Output is correct
24 Correct 3 ms 692 KB Output is correct
25 Correct 3 ms 716 KB Output is correct
26 Correct 9 ms 844 KB Output is correct
27 Correct 8 ms 844 KB Output is correct
28 Correct 5 ms 844 KB Output is correct
29 Correct 4 ms 844 KB Output is correct
30 Correct 4 ms 844 KB Output is correct
31 Correct 10 ms 876 KB Output is correct
32 Correct 8 ms 1004 KB Output is correct
33 Correct 8 ms 1004 KB Output is correct
34 Correct 2 ms 1004 KB Output is correct
35 Correct 2 ms 1004 KB Output is correct
36 Correct 3 ms 1004 KB Output is correct
37 Correct 6 ms 1004 KB Output is correct
38 Correct 3 ms 1004 KB Output is correct
39 Correct 2 ms 1004 KB Output is correct
40 Correct 5 ms 1004 KB Output is correct
41 Correct 2 ms 1004 KB Output is correct
42 Correct 2 ms 1004 KB Output is correct
43 Correct 2 ms 1004 KB Output is correct
44 Correct 2 ms 1004 KB Output is correct
45 Correct 3 ms 1004 KB Output is correct
46 Correct 3 ms 1004 KB Output is correct
47 Correct 6 ms 1004 KB Output is correct
48 Correct 2 ms 1004 KB Output is correct
49 Correct 3 ms 1004 KB Output is correct
50 Correct 36 ms 1788 KB Output is correct
51 Correct 40 ms 1788 KB Output is correct
52 Correct 29 ms 1788 KB Output is correct
53 Correct 30 ms 1788 KB Output is correct
54 Correct 13 ms 1788 KB Output is correct
55 Correct 50 ms 2044 KB Output is correct
56 Correct 43 ms 2044 KB Output is correct
57 Correct 39 ms 2044 KB Output is correct
58 Correct 2 ms 2044 KB Output is correct
59 Correct 3 ms 2044 KB Output is correct
60 Correct 5 ms 2044 KB Output is correct
61 Correct 27 ms 2044 KB Output is correct
62 Correct 11 ms 2044 KB Output is correct
63 Correct 11 ms 2044 KB Output is correct
64 Correct 3 ms 2044 KB Output is correct
65 Correct 21 ms 2044 KB Output is correct
66 Correct 2 ms 2044 KB Output is correct
67 Correct 2 ms 2044 KB Output is correct
68 Correct 3 ms 2044 KB Output is correct
69 Correct 4 ms 2044 KB Output is correct
70 Correct 11 ms 2044 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 356 KB Output is correct
3 Correct 3 ms 432 KB Output is correct
4 Correct 3 ms 468 KB Output is correct
5 Correct 3 ms 596 KB Output is correct
6 Correct 3 ms 596 KB Output is correct
7 Correct 2 ms 596 KB Output is correct
8 Correct 2 ms 596 KB Output is correct
9 Correct 2 ms 596 KB Output is correct
10 Correct 2 ms 660 KB Output is correct
11 Correct 2 ms 660 KB Output is correct
12 Correct 3 ms 660 KB Output is correct
13 Correct 3 ms 692 KB Output is correct
14 Correct 3 ms 692 KB Output is correct
15 Correct 2 ms 692 KB Output is correct
16 Correct 2 ms 692 KB Output is correct
17 Correct 4 ms 692 KB Output is correct
18 Correct 3 ms 692 KB Output is correct
19 Correct 2 ms 692 KB Output is correct
20 Correct 2 ms 692 KB Output is correct
21 Correct 2 ms 692 KB Output is correct
22 Correct 2 ms 692 KB Output is correct
23 Correct 3 ms 692 KB Output is correct
24 Correct 3 ms 692 KB Output is correct
25 Correct 3 ms 716 KB Output is correct
26 Correct 9 ms 844 KB Output is correct
27 Correct 8 ms 844 KB Output is correct
28 Correct 5 ms 844 KB Output is correct
29 Correct 4 ms 844 KB Output is correct
30 Correct 4 ms 844 KB Output is correct
31 Correct 10 ms 876 KB Output is correct
32 Correct 8 ms 1004 KB Output is correct
33 Correct 8 ms 1004 KB Output is correct
34 Correct 2 ms 1004 KB Output is correct
35 Correct 2 ms 1004 KB Output is correct
36 Correct 3 ms 1004 KB Output is correct
37 Correct 6 ms 1004 KB Output is correct
38 Correct 3 ms 1004 KB Output is correct
39 Correct 2 ms 1004 KB Output is correct
40 Correct 5 ms 1004 KB Output is correct
41 Correct 2 ms 1004 KB Output is correct
42 Correct 2 ms 1004 KB Output is correct
43 Correct 2 ms 1004 KB Output is correct
44 Correct 2 ms 1004 KB Output is correct
45 Correct 3 ms 1004 KB Output is correct
46 Correct 3 ms 1004 KB Output is correct
47 Correct 6 ms 1004 KB Output is correct
48 Correct 2 ms 1004 KB Output is correct
49 Correct 3 ms 1004 KB Output is correct
50 Correct 36 ms 1788 KB Output is correct
51 Correct 40 ms 1788 KB Output is correct
52 Correct 29 ms 1788 KB Output is correct
53 Correct 30 ms 1788 KB Output is correct
54 Correct 13 ms 1788 KB Output is correct
55 Correct 50 ms 2044 KB Output is correct
56 Correct 43 ms 2044 KB Output is correct
57 Correct 39 ms 2044 KB Output is correct
58 Correct 2 ms 2044 KB Output is correct
59 Correct 3 ms 2044 KB Output is correct
60 Correct 5 ms 2044 KB Output is correct
61 Correct 27 ms 2044 KB Output is correct
62 Correct 11 ms 2044 KB Output is correct
63 Correct 11 ms 2044 KB Output is correct
64 Correct 3 ms 2044 KB Output is correct
65 Correct 21 ms 2044 KB Output is correct
66 Correct 2 ms 2044 KB Output is correct
67 Correct 2 ms 2044 KB Output is correct
68 Correct 3 ms 2044 KB Output is correct
69 Correct 4 ms 2044 KB Output is correct
70 Correct 11 ms 2044 KB Output is correct
71 Execution timed out 5037 ms 56572 KB Time limit exceeded
72 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 356 KB Output is correct
3 Correct 3 ms 432 KB Output is correct
4 Correct 3 ms 468 KB Output is correct
5 Correct 3 ms 596 KB Output is correct
6 Correct 3 ms 596 KB Output is correct
7 Correct 2 ms 596 KB Output is correct
8 Correct 2 ms 596 KB Output is correct
9 Correct 2 ms 596 KB Output is correct
10 Correct 2 ms 660 KB Output is correct
11 Correct 2 ms 660 KB Output is correct
12 Correct 3 ms 660 KB Output is correct
13 Correct 3 ms 692 KB Output is correct
14 Correct 3 ms 692 KB Output is correct
15 Correct 2 ms 692 KB Output is correct
16 Correct 2 ms 692 KB Output is correct
17 Correct 4 ms 692 KB Output is correct
18 Correct 3 ms 692 KB Output is correct
19 Correct 2 ms 692 KB Output is correct
20 Correct 2 ms 692 KB Output is correct
21 Correct 2 ms 692 KB Output is correct
22 Correct 2 ms 692 KB Output is correct
23 Correct 3 ms 692 KB Output is correct
24 Correct 3 ms 692 KB Output is correct
25 Correct 3 ms 716 KB Output is correct
26 Correct 9 ms 844 KB Output is correct
27 Correct 8 ms 844 KB Output is correct
28 Correct 5 ms 844 KB Output is correct
29 Correct 4 ms 844 KB Output is correct
30 Correct 4 ms 844 KB Output is correct
31 Correct 10 ms 876 KB Output is correct
32 Correct 8 ms 1004 KB Output is correct
33 Correct 8 ms 1004 KB Output is correct
34 Correct 2 ms 1004 KB Output is correct
35 Correct 2 ms 1004 KB Output is correct
36 Correct 3 ms 1004 KB Output is correct
37 Correct 6 ms 1004 KB Output is correct
38 Correct 3 ms 1004 KB Output is correct
39 Correct 2 ms 1004 KB Output is correct
40 Correct 5 ms 1004 KB Output is correct
41 Correct 2 ms 1004 KB Output is correct
42 Correct 2 ms 1004 KB Output is correct
43 Correct 2 ms 1004 KB Output is correct
44 Correct 2 ms 1004 KB Output is correct
45 Correct 3 ms 1004 KB Output is correct
46 Correct 3 ms 1004 KB Output is correct
47 Correct 6 ms 1004 KB Output is correct
48 Correct 2 ms 1004 KB Output is correct
49 Correct 3 ms 1004 KB Output is correct
50 Correct 36 ms 1788 KB Output is correct
51 Correct 40 ms 1788 KB Output is correct
52 Correct 29 ms 1788 KB Output is correct
53 Correct 30 ms 1788 KB Output is correct
54 Correct 13 ms 1788 KB Output is correct
55 Correct 50 ms 2044 KB Output is correct
56 Correct 43 ms 2044 KB Output is correct
57 Correct 39 ms 2044 KB Output is correct
58 Correct 2 ms 2044 KB Output is correct
59 Correct 3 ms 2044 KB Output is correct
60 Correct 5 ms 2044 KB Output is correct
61 Correct 27 ms 2044 KB Output is correct
62 Correct 11 ms 2044 KB Output is correct
63 Correct 11 ms 2044 KB Output is correct
64 Correct 3 ms 2044 KB Output is correct
65 Correct 21 ms 2044 KB Output is correct
66 Correct 2 ms 2044 KB Output is correct
67 Correct 2 ms 2044 KB Output is correct
68 Correct 3 ms 2044 KB Output is correct
69 Correct 4 ms 2044 KB Output is correct
70 Correct 11 ms 2044 KB Output is correct
71 Execution timed out 5037 ms 56572 KB Time limit exceeded
72 Halted 0 ms 0 KB -