Submission #267157

#TimeUsernameProblemLanguageResultExecution timeMemory
267157ly20Toys (CEOI18_toy)C++17
59 / 100
5067 ms712 KiB
#include <bits/stdc++.h>
using namespace std;
set <int> resp;
void backt(int at, int tot) {
	 //printf("%d\n", at);
	int sq = min((int) sqrt(at) + 10, at);
	if(at == 1) {
		resp.insert(tot);
		return;
	}
	for(int i = 2; i < sq; i++) {
		if(at % i == 0) {
			backt(at / i, tot + i - 1);
			backt(i, tot + at / i - 1);
		}
	} 
	backt(1, tot + at - 1);
}
int main() {
	int n;
	scanf("%d", &n);
	backt(n, 0);
	set <int> :: iterator it;
	printf("%d\n", resp.size());
	for(it = resp.begin(); it != resp.end(); it++) {
		printf("%d ", *it);
	}
	printf("\n");
	return 0;
}

Compilation message (stderr)

toy.cpp: In function 'int main()':
toy.cpp:24:11: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::set<int>::size_type' {aka 'long unsigned int'} [-Wformat=]
   24 |  printf("%d\n", resp.size());
      |          ~^     ~~~~~~~~~~~
      |           |              |
      |           int            std::set<int>::size_type {aka long unsigned int}
      |          %ld
toy.cpp:21:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   21 |  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...