Submission #81805

#TimeUsernameProblemLanguageResultExecution timeMemory
81805xiaowuc1Toys (CEOI18_toy)C++14
100 / 100
717 ms5264 KiB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

set<int> ret;

void solve(int n, int k, int x) {
	if(n == 1) {
		ret.insert(x);
		return;
	}
	if(n < k) return;
	for(int i = k; i * i <= n; i++) {
		int t = n;
		int nx = x;
		while(t%i == 0) {
			t /= i;
			nx += i-1;
			solve(t, i+1, nx);
		}
	}
	ret.insert(n+x-1);
}

void solve(int n) {
	solve(n, 2, 0);
}

int main() {
	int n;
	scanf("%d", &n);
	solve(n);
	printf("%d\n", ret.size());
	for(int x: ret) {
		printf("%d", x);
		if(x == *ret.rbegin()) printf("\n");
		else printf(" ");
	}
}

Compilation message (stderr)

toy.cpp: In function 'int main()':
toy.cpp:35:27: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::set<int>::size_type {aka long unsigned int}' [-Wformat=]
  printf("%d\n", ret.size());
                 ~~~~~~~~~~^
toy.cpp:33:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
  ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...