Submission #291655

# Submission time Handle Problem Language Result Execution time Memory
291655 2020-09-05T15:20:29 Z NaimSS Toys (CEOI18_toy) C++14
100 / 100
1272 ms 121564 KB
#include <bits/stdc++.h>
#define ld long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define per(i, a, b) for(int i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define Unique(v) sort(all(v));v.erase(unique(all(v)),v.end());
#define sz(v) (int)v.size()
//#define int long long
using namespace std;
typedef vector<int> vi;
#define y1 abacaba
#define left sefude
#define db(x) cerr << #x <<" == "<<x << endl;
#define db2(x,y) cerr<<#x <<" == "<<x<<", "<<#y<<" == "<<y<<endl;
#define db3(x,y,z) cerr << #x<<" == "<<x<<", "<<#y<<" == "<<y<<", "<<#z<<" == "<<z<<endl; 
typedef long long ll;
typedef pair<int,int> pii;
inline ll mod(ll n, ll m ){ ll ret = n%m; if(ret < 0) ret += m; return ret; }
ll gcd(ll a, ll b){return (b == 0LL ? a : gcd(b, a%b));}
ll exp(ll a,ll b,ll m){
    if(b==0LL) return 1LL;
    if(b==1LL) return mod(a,m);
    ll k = mod(exp(a,b/2,m),m);
    if(b&1LL){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
}


map<int,int> vis,id;
int ID=0;
vi can[123100];
void go(int n){
  if(vis[n])return;
  vis[n]=1;
  id[n] = ID++;
  int cur = id[n];
  if(n == 1){
    can[cur].pb(0);
    return;
  }
  for(int i=1;i*i<=n;i++){
      if(n%i==0){
        if(i!=1){
          go(n/i);
          int Id = id[n/i];
          for(int val : can[Id]){
            can[cur].pb(val+i-1);
          }
        }
        if(n/i!=i){
          go(n/(n/i));
          int Id = id[n/(n/i)];
          for(int val : can[Id]){
            can[cur].pb(val + (n/i) - 1);
          }
        }
      }
  }
  Unique(can[cur]);
  return;
}


int32_t main(){
  fastio;
  int n;
  cin >> n;
  go(n);
  cout << sz(can[id[n]]) << endl;
  for(int x : can[id[n]]){
    cout << x<<" ";
  }
  cout << endl;
  return 0;
  // math -> gcd it all
  // Did u check N=1? Did you switch N,M?
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3200 KB Output is correct
2 Correct 2 ms 3200 KB Output is correct
3 Correct 2 ms 3200 KB Output is correct
4 Correct 2 ms 3200 KB Output is correct
5 Correct 2 ms 3328 KB Output is correct
6 Correct 2 ms 3200 KB Output is correct
7 Correct 2 ms 3200 KB Output is correct
8 Correct 2 ms 3200 KB Output is correct
9 Correct 2 ms 3200 KB Output is correct
10 Correct 2 ms 3200 KB Output is correct
11 Correct 2 ms 3200 KB Output is correct
12 Correct 2 ms 3200 KB Output is correct
13 Correct 2 ms 3200 KB Output is correct
14 Correct 2 ms 3200 KB Output is correct
15 Correct 2 ms 3200 KB Output is correct
16 Correct 2 ms 3200 KB Output is correct
17 Correct 2 ms 3200 KB Output is correct
18 Correct 2 ms 3200 KB Output is correct
19 Correct 2 ms 3200 KB Output is correct
20 Correct 2 ms 3200 KB Output is correct
21 Correct 2 ms 3200 KB Output is correct
22 Correct 2 ms 3200 KB Output is correct
23 Correct 2 ms 3200 KB Output is correct
24 Correct 2 ms 3200 KB Output is correct
25 Correct 3 ms 3200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3200 KB Output is correct
2 Correct 2 ms 3200 KB Output is correct
3 Correct 2 ms 3200 KB Output is correct
4 Correct 2 ms 3200 KB Output is correct
5 Correct 2 ms 3328 KB Output is correct
6 Correct 2 ms 3200 KB Output is correct
7 Correct 2 ms 3200 KB Output is correct
8 Correct 2 ms 3200 KB Output is correct
9 Correct 2 ms 3200 KB Output is correct
10 Correct 2 ms 3200 KB Output is correct
11 Correct 2 ms 3200 KB Output is correct
12 Correct 2 ms 3200 KB Output is correct
13 Correct 2 ms 3200 KB Output is correct
14 Correct 2 ms 3200 KB Output is correct
15 Correct 2 ms 3200 KB Output is correct
16 Correct 2 ms 3200 KB Output is correct
17 Correct 2 ms 3200 KB Output is correct
18 Correct 2 ms 3200 KB Output is correct
19 Correct 2 ms 3200 KB Output is correct
20 Correct 2 ms 3200 KB Output is correct
21 Correct 2 ms 3200 KB Output is correct
22 Correct 2 ms 3200 KB Output is correct
23 Correct 2 ms 3200 KB Output is correct
24 Correct 2 ms 3200 KB Output is correct
25 Correct 3 ms 3200 KB Output is correct
26 Correct 3 ms 3328 KB Output is correct
27 Correct 3 ms 3328 KB Output is correct
28 Correct 3 ms 3200 KB Output is correct
29 Correct 2 ms 3200 KB Output is correct
30 Correct 2 ms 3200 KB Output is correct
31 Correct 3 ms 3328 KB Output is correct
32 Correct 3 ms 3328 KB Output is correct
33 Correct 3 ms 3328 KB Output is correct
34 Correct 2 ms 3200 KB Output is correct
35 Correct 3 ms 3200 KB Output is correct
36 Correct 2 ms 3200 KB Output is correct
37 Correct 3 ms 3200 KB Output is correct
38 Correct 2 ms 3200 KB Output is correct
39 Correct 2 ms 3200 KB Output is correct
40 Correct 3 ms 3200 KB Output is correct
41 Correct 2 ms 3200 KB Output is correct
42 Correct 2 ms 3200 KB Output is correct
43 Correct 2 ms 3200 KB Output is correct
44 Correct 2 ms 3200 KB Output is correct
45 Correct 2 ms 3200 KB Output is correct
46 Correct 2 ms 3200 KB Output is correct
47 Correct 3 ms 3200 KB Output is correct
48 Correct 2 ms 3200 KB Output is correct
49 Correct 2 ms 3200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3200 KB Output is correct
2 Correct 2 ms 3200 KB Output is correct
3 Correct 2 ms 3200 KB Output is correct
4 Correct 2 ms 3200 KB Output is correct
5 Correct 2 ms 3328 KB Output is correct
6 Correct 2 ms 3200 KB Output is correct
7 Correct 2 ms 3200 KB Output is correct
8 Correct 2 ms 3200 KB Output is correct
9 Correct 2 ms 3200 KB Output is correct
10 Correct 2 ms 3200 KB Output is correct
11 Correct 2 ms 3200 KB Output is correct
12 Correct 2 ms 3200 KB Output is correct
13 Correct 2 ms 3200 KB Output is correct
14 Correct 2 ms 3200 KB Output is correct
15 Correct 2 ms 3200 KB Output is correct
16 Correct 2 ms 3200 KB Output is correct
17 Correct 2 ms 3200 KB Output is correct
18 Correct 2 ms 3200 KB Output is correct
19 Correct 2 ms 3200 KB Output is correct
20 Correct 2 ms 3200 KB Output is correct
21 Correct 2 ms 3200 KB Output is correct
22 Correct 2 ms 3200 KB Output is correct
23 Correct 2 ms 3200 KB Output is correct
24 Correct 2 ms 3200 KB Output is correct
25 Correct 3 ms 3200 KB Output is correct
26 Correct 3 ms 3328 KB Output is correct
27 Correct 3 ms 3328 KB Output is correct
28 Correct 3 ms 3200 KB Output is correct
29 Correct 2 ms 3200 KB Output is correct
30 Correct 2 ms 3200 KB Output is correct
31 Correct 3 ms 3328 KB Output is correct
32 Correct 3 ms 3328 KB Output is correct
33 Correct 3 ms 3328 KB Output is correct
34 Correct 2 ms 3200 KB Output is correct
35 Correct 3 ms 3200 KB Output is correct
36 Correct 2 ms 3200 KB Output is correct
37 Correct 3 ms 3200 KB Output is correct
38 Correct 2 ms 3200 KB Output is correct
39 Correct 2 ms 3200 KB Output is correct
40 Correct 3 ms 3200 KB Output is correct
41 Correct 2 ms 3200 KB Output is correct
42 Correct 2 ms 3200 KB Output is correct
43 Correct 2 ms 3200 KB Output is correct
44 Correct 2 ms 3200 KB Output is correct
45 Correct 2 ms 3200 KB Output is correct
46 Correct 2 ms 3200 KB Output is correct
47 Correct 3 ms 3200 KB Output is correct
48 Correct 2 ms 3200 KB Output is correct
49 Correct 2 ms 3200 KB Output is correct
50 Correct 4 ms 3456 KB Output is correct
51 Correct 4 ms 3456 KB Output is correct
52 Correct 4 ms 3456 KB Output is correct
53 Correct 4 ms 3456 KB Output is correct
54 Correct 3 ms 3328 KB Output is correct
55 Correct 5 ms 3484 KB Output is correct
56 Correct 5 ms 3456 KB Output is correct
57 Correct 5 ms 3584 KB Output is correct
58 Correct 3 ms 3200 KB Output is correct
59 Correct 2 ms 3200 KB Output is correct
60 Correct 3 ms 3328 KB Output is correct
61 Correct 3 ms 3328 KB Output is correct
62 Correct 3 ms 3328 KB Output is correct
63 Correct 2 ms 3200 KB Output is correct
64 Correct 2 ms 3200 KB Output is correct
65 Correct 3 ms 3328 KB Output is correct
66 Correct 3 ms 3200 KB Output is correct
67 Correct 2 ms 3200 KB Output is correct
68 Correct 2 ms 3200 KB Output is correct
69 Correct 2 ms 3200 KB Output is correct
70 Correct 3 ms 3328 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3200 KB Output is correct
2 Correct 2 ms 3200 KB Output is correct
3 Correct 2 ms 3200 KB Output is correct
4 Correct 2 ms 3200 KB Output is correct
5 Correct 2 ms 3328 KB Output is correct
6 Correct 2 ms 3200 KB Output is correct
7 Correct 2 ms 3200 KB Output is correct
8 Correct 2 ms 3200 KB Output is correct
9 Correct 2 ms 3200 KB Output is correct
10 Correct 2 ms 3200 KB Output is correct
11 Correct 2 ms 3200 KB Output is correct
12 Correct 2 ms 3200 KB Output is correct
13 Correct 2 ms 3200 KB Output is correct
14 Correct 2 ms 3200 KB Output is correct
15 Correct 2 ms 3200 KB Output is correct
16 Correct 2 ms 3200 KB Output is correct
17 Correct 2 ms 3200 KB Output is correct
18 Correct 2 ms 3200 KB Output is correct
19 Correct 2 ms 3200 KB Output is correct
20 Correct 2 ms 3200 KB Output is correct
21 Correct 2 ms 3200 KB Output is correct
22 Correct 2 ms 3200 KB Output is correct
23 Correct 2 ms 3200 KB Output is correct
24 Correct 2 ms 3200 KB Output is correct
25 Correct 3 ms 3200 KB Output is correct
26 Correct 3 ms 3328 KB Output is correct
27 Correct 3 ms 3328 KB Output is correct
28 Correct 3 ms 3200 KB Output is correct
29 Correct 2 ms 3200 KB Output is correct
30 Correct 2 ms 3200 KB Output is correct
31 Correct 3 ms 3328 KB Output is correct
32 Correct 3 ms 3328 KB Output is correct
33 Correct 3 ms 3328 KB Output is correct
34 Correct 2 ms 3200 KB Output is correct
35 Correct 3 ms 3200 KB Output is correct
36 Correct 2 ms 3200 KB Output is correct
37 Correct 3 ms 3200 KB Output is correct
38 Correct 2 ms 3200 KB Output is correct
39 Correct 2 ms 3200 KB Output is correct
40 Correct 3 ms 3200 KB Output is correct
41 Correct 2 ms 3200 KB Output is correct
42 Correct 2 ms 3200 KB Output is correct
43 Correct 2 ms 3200 KB Output is correct
44 Correct 2 ms 3200 KB Output is correct
45 Correct 2 ms 3200 KB Output is correct
46 Correct 2 ms 3200 KB Output is correct
47 Correct 3 ms 3200 KB Output is correct
48 Correct 2 ms 3200 KB Output is correct
49 Correct 2 ms 3200 KB Output is correct
50 Correct 4 ms 3456 KB Output is correct
51 Correct 4 ms 3456 KB Output is correct
52 Correct 4 ms 3456 KB Output is correct
53 Correct 4 ms 3456 KB Output is correct
54 Correct 3 ms 3328 KB Output is correct
55 Correct 5 ms 3484 KB Output is correct
56 Correct 5 ms 3456 KB Output is correct
57 Correct 5 ms 3584 KB Output is correct
58 Correct 3 ms 3200 KB Output is correct
59 Correct 2 ms 3200 KB Output is correct
60 Correct 3 ms 3328 KB Output is correct
61 Correct 3 ms 3328 KB Output is correct
62 Correct 3 ms 3328 KB Output is correct
63 Correct 2 ms 3200 KB Output is correct
64 Correct 2 ms 3200 KB Output is correct
65 Correct 3 ms 3328 KB Output is correct
66 Correct 3 ms 3200 KB Output is correct
67 Correct 2 ms 3200 KB Output is correct
68 Correct 2 ms 3200 KB Output is correct
69 Correct 2 ms 3200 KB Output is correct
70 Correct 3 ms 3328 KB Output is correct
71 Correct 194 ms 21484 KB Output is correct
72 Correct 138 ms 16236 KB Output is correct
73 Correct 185 ms 20716 KB Output is correct
74 Correct 104 ms 12656 KB Output is correct
75 Correct 120 ms 13988 KB Output is correct
76 Correct 304 ms 31336 KB Output is correct
77 Correct 275 ms 29544 KB Output is correct
78 Correct 241 ms 25048 KB Output is correct
79 Correct 234 ms 25832 KB Output is correct
80 Correct 2 ms 3200 KB Output is correct
81 Correct 2 ms 3200 KB Output is correct
82 Correct 4 ms 3456 KB Output is correct
83 Correct 29 ms 6012 KB Output is correct
84 Correct 37 ms 6908 KB Output is correct
85 Correct 10 ms 4096 KB Output is correct
86 Correct 3 ms 3200 KB Output is correct
87 Correct 40 ms 7036 KB Output is correct
88 Correct 3 ms 3200 KB Output is correct
89 Correct 2 ms 3200 KB Output is correct
90 Correct 3 ms 3200 KB Output is correct
91 Correct 13 ms 4096 KB Output is correct
92 Correct 49 ms 7156 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3200 KB Output is correct
2 Correct 2 ms 3200 KB Output is correct
3 Correct 2 ms 3200 KB Output is correct
4 Correct 2 ms 3200 KB Output is correct
5 Correct 2 ms 3328 KB Output is correct
6 Correct 2 ms 3200 KB Output is correct
7 Correct 2 ms 3200 KB Output is correct
8 Correct 2 ms 3200 KB Output is correct
9 Correct 2 ms 3200 KB Output is correct
10 Correct 2 ms 3200 KB Output is correct
11 Correct 2 ms 3200 KB Output is correct
12 Correct 2 ms 3200 KB Output is correct
13 Correct 2 ms 3200 KB Output is correct
14 Correct 2 ms 3200 KB Output is correct
15 Correct 2 ms 3200 KB Output is correct
16 Correct 2 ms 3200 KB Output is correct
17 Correct 2 ms 3200 KB Output is correct
18 Correct 2 ms 3200 KB Output is correct
19 Correct 2 ms 3200 KB Output is correct
20 Correct 2 ms 3200 KB Output is correct
21 Correct 2 ms 3200 KB Output is correct
22 Correct 2 ms 3200 KB Output is correct
23 Correct 2 ms 3200 KB Output is correct
24 Correct 2 ms 3200 KB Output is correct
25 Correct 3 ms 3200 KB Output is correct
26 Correct 3 ms 3328 KB Output is correct
27 Correct 3 ms 3328 KB Output is correct
28 Correct 3 ms 3200 KB Output is correct
29 Correct 2 ms 3200 KB Output is correct
30 Correct 2 ms 3200 KB Output is correct
31 Correct 3 ms 3328 KB Output is correct
32 Correct 3 ms 3328 KB Output is correct
33 Correct 3 ms 3328 KB Output is correct
34 Correct 2 ms 3200 KB Output is correct
35 Correct 3 ms 3200 KB Output is correct
36 Correct 2 ms 3200 KB Output is correct
37 Correct 3 ms 3200 KB Output is correct
38 Correct 2 ms 3200 KB Output is correct
39 Correct 2 ms 3200 KB Output is correct
40 Correct 3 ms 3200 KB Output is correct
41 Correct 2 ms 3200 KB Output is correct
42 Correct 2 ms 3200 KB Output is correct
43 Correct 2 ms 3200 KB Output is correct
44 Correct 2 ms 3200 KB Output is correct
45 Correct 2 ms 3200 KB Output is correct
46 Correct 2 ms 3200 KB Output is correct
47 Correct 3 ms 3200 KB Output is correct
48 Correct 2 ms 3200 KB Output is correct
49 Correct 2 ms 3200 KB Output is correct
50 Correct 4 ms 3456 KB Output is correct
51 Correct 4 ms 3456 KB Output is correct
52 Correct 4 ms 3456 KB Output is correct
53 Correct 4 ms 3456 KB Output is correct
54 Correct 3 ms 3328 KB Output is correct
55 Correct 5 ms 3484 KB Output is correct
56 Correct 5 ms 3456 KB Output is correct
57 Correct 5 ms 3584 KB Output is correct
58 Correct 3 ms 3200 KB Output is correct
59 Correct 2 ms 3200 KB Output is correct
60 Correct 3 ms 3328 KB Output is correct
61 Correct 3 ms 3328 KB Output is correct
62 Correct 3 ms 3328 KB Output is correct
63 Correct 2 ms 3200 KB Output is correct
64 Correct 2 ms 3200 KB Output is correct
65 Correct 3 ms 3328 KB Output is correct
66 Correct 3 ms 3200 KB Output is correct
67 Correct 2 ms 3200 KB Output is correct
68 Correct 2 ms 3200 KB Output is correct
69 Correct 2 ms 3200 KB Output is correct
70 Correct 3 ms 3328 KB Output is correct
71 Correct 194 ms 21484 KB Output is correct
72 Correct 138 ms 16236 KB Output is correct
73 Correct 185 ms 20716 KB Output is correct
74 Correct 104 ms 12656 KB Output is correct
75 Correct 120 ms 13988 KB Output is correct
76 Correct 304 ms 31336 KB Output is correct
77 Correct 275 ms 29544 KB Output is correct
78 Correct 241 ms 25048 KB Output is correct
79 Correct 234 ms 25832 KB Output is correct
80 Correct 2 ms 3200 KB Output is correct
81 Correct 2 ms 3200 KB Output is correct
82 Correct 4 ms 3456 KB Output is correct
83 Correct 29 ms 6012 KB Output is correct
84 Correct 37 ms 6908 KB Output is correct
85 Correct 10 ms 4096 KB Output is correct
86 Correct 3 ms 3200 KB Output is correct
87 Correct 40 ms 7036 KB Output is correct
88 Correct 3 ms 3200 KB Output is correct
89 Correct 2 ms 3200 KB Output is correct
90 Correct 3 ms 3200 KB Output is correct
91 Correct 13 ms 4096 KB Output is correct
92 Correct 49 ms 7156 KB Output is correct
93 Correct 1065 ms 100456 KB Output is correct
94 Correct 600 ms 55776 KB Output is correct
95 Correct 691 ms 67324 KB Output is correct
96 Correct 612 ms 58980 KB Output is correct
97 Correct 571 ms 55792 KB Output is correct
98 Correct 1209 ms 114756 KB Output is correct
99 Correct 1272 ms 121564 KB Output is correct
100 Correct 1177 ms 113324 KB Output is correct
101 Correct 1126 ms 108180 KB Output is correct
102 Correct 1000 ms 96100 KB Output is correct
103 Correct 789 ms 76260 KB Output is correct
104 Correct 3 ms 3200 KB Output is correct
105 Correct 3 ms 3200 KB Output is correct
106 Correct 6 ms 3584 KB Output is correct
107 Correct 87 ms 11376 KB Output is correct
108 Correct 217 ms 23016 KB Output is correct
109 Correct 22 ms 5116 KB Output is correct
110 Correct 3 ms 3200 KB Output is correct
111 Correct 117 ms 13804 KB Output is correct
112 Correct 3 ms 3200 KB Output is correct
113 Correct 3 ms 3200 KB Output is correct
114 Correct 8 ms 3576 KB Output is correct
115 Correct 3 ms 3200 KB Output is correct
116 Correct 11 ms 3968 KB Output is correct
117 Correct 215 ms 21228 KB Output is correct