This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define fr first
#define sc second
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
int n, x, a, b;
vector<int> vc[100069], fac;
int main()
{
int i, j;
scanf("%d", &n);
for (i=1; i*i<=n; i++)
{
if (n%i == 0)
{
fac.push_back(i);
if (i != n/i) fac.push_back(n/i);
}
}
sort(fac.begin(), fac.end());
vc[0].push_back(0);
for (i=1; i<fac.size(); i++)
{
x = fac[i];
// printf("x = %d\n", x);
for (j=0; j<=i-1; j++)
{
a = fac[j];
if (x%a != 0) continue;
b = x/a;
// printf("a = %d b = %d\n", a, b);
//b nya bisa di-split lagi boz
for (auto f:vc[j])
{
vc[i].push_back(f+b-1);
}
}
sort(vc[i].begin(), vc[i].end());
vc[i].resize(unique(vc[i].begin(), vc[i].end())-vc[i].begin());
}
printf("%d\n", (int)vc[fac.size()-1].size());
for (auto x:vc[fac.size()-1]) printf("%d ", x);
printf("\n");
}
Compilation message (stderr)
toy.cpp: In function 'int main()':
toy.cpp:24:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
24 | for (i=1; i<fac.size(); i++)
| ~^~~~~~~~~~~
toy.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
13 | scanf("%d", &n);
| ~~~~~^~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |