Submission #70540

# Submission time Handle Problem Language Result Execution time Memory
70540 2018-08-23T05:42:32 Z 조승현(#2190) Fibonacci representations (CEOI18_fib) C++11
0 / 100
3 ms 544 KB
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
vector<int>T;
void Calc(int a, int b, int s) {
	if (a == 1) {
		T.push_back(s);
		return;
	}
	if (1ll*b*b <= a) {
		for (int i = b; i >= 2; i--) {
			if (a%i == 0) {
				Calc(a / i, i, s+i-1);
			}
		}
	}
	else {
		for (int i = 1; i*i <= a; i++) {
			if (a%i == 0 && a/i<=b) {
				Calc(i, a / i, s + a / i - 1);
			}
		}
		for (int i = 1; i*i < a; i++) {
			if (a%i == 0) {
				Calc(a / i, i, s + i - 1);
			}
		}
	}
}
int main() {
	freopen("output.txt", "w", stdout);
	int n;
	scanf("%d", &n);
	if (n == 1) {
		printf("1\n0\n");
		return 0;
	}
	Calc(n,n,0);
	sort(T.begin(), T.end());
	T.resize(unique(T.begin(), T.end()) - T.begin());
	printf("%d\n", T.size());
	for (auto &x : T)printf("%d ", x);
}

Compilation message

fib.cpp: In function 'int main()':
fib.cpp:42:25: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::vector<int>::size_type {aka long unsigned int}' [-Wformat=]
  printf("%d\n", T.size());
                 ~~~~~~~~^
fib.cpp:32:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
  freopen("output.txt", "w", stdout);
  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
fib.cpp:34:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
  ~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 544 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 544 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -