# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
490984 |
2021-11-30T02:49:05 Z |
Mike4235 |
Toys (CEOI18_toy) |
C++17 |
|
0 ms |
204 KB |
/*#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,fma")*/
#include <bits/stdc++.h>
#define for1(i,a,b) for (int i = a; i <= b; i++)
#define for2(i,a,b) for (int i = a; i >= b; i--)
// #define int long long
#define sz(a) (int)a.size()
#define pii pair<int,int>
#define pb push_back
/*
__builtin_popcountll(x) : Number of 1-bit
__builtin_ctzll(x) : Number of trailing 0
*/
const long double PI = 3.1415926535897932384626433832795;
const int INF = 1000000000000000000;
const int MOD = 1000000007;
const int MOD2 = 1000000009;
const long double EPS = 1e-6;
using namespace std;
vector<int> v, d;
void solve(int x, int pos, int sum) {
if (x == 1) {
v.push_back(sum);
return;
}
if (pos == sz(d)) return;
solve(x, pos + 1, sum);
while (x % d[pos] == 0) {
x /= d[pos]; sum += d[pos] - 1;
solve(x, pos + 1, sum);
}
}
signed main() {
ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
// freopen("cf.inp", "r", stdin);
// freopen("cf.out", "w", stdout);
int n;
cin >> n;
for (int i = 2; i * i <= n; i++) if (n % i == 0) {
d.push_back(i);
if (n / i != i) d.push_back(n / i);
}
sort(d.begin(), d.end());
solve(n, 0, 0);
sort(v.begin(), v.end());
v.erase(unique(v.begin(), v.end()), v.end());
v.push_back(n - 1);
cout << sz(v) << "\n";
for (auto x : v) cout << x << " ";
}
Compilation message
toy.cpp:21:17: warning: overflow in conversion from 'long int' to 'int' changes value from '1000000000000000000' to '-1486618624' [-Woverflow]
21 | const int INF = 1000000000000000000;
| ^~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |