Submission #267156

# Submission time Handle Problem Language Result Execution time Memory
267156 2020-08-15T22:19:14 Z peuch Fibonacci representations (CEOI18_fib) C++17
5 / 100
68 ms 632 KB
#include<bits/stdc++.h>
using namespace std;

const int MAXN = 20;

int n;
int f[MAXN];
int sum;
int ans[2000000];

int main(){
	f[1] = 1;
	f[2] = 2;
	for(int i = 3; i <= 20; i++){
		f[i] = f[i - 1] + f[i - 2];
	}
	for(int i = 0; i < (1<<20); i++){
		int aux = 0;
		for(int k = 0; k < 20; k++)
			if(i & (1<<k)) aux += f[k + 1];
		ans[aux]++;
	}
	scanf("%d", &n);
	for(int i = 1; i <= n; i++){
		int aux;
		scanf("%d", &aux);
		sum += f[aux];
		printf("%d\n", ans[sum]);
	}
}

Compilation message

fib.cpp: In function 'int main()':
fib.cpp:23:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   23 |  scanf("%d", &n);
      |  ~~~~~^~~~~~~~~~
fib.cpp:26:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   26 |   scanf("%d", &aux);
      |   ~~~~~^~~~~~~~~~~~
fib.cpp:15:8: warning: iteration 17 invokes undefined behavior [-Waggressive-loop-optimizations]
   15 |   f[i] = f[i - 1] + f[i - 2];
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~
fib.cpp:14:19: note: within this loop
   14 |  for(int i = 3; i <= 20; i++){
      |                 ~~^~~~~
# Verdict Execution time Memory Grader output
1 Correct 66 ms 504 KB Output is correct
2 Correct 65 ms 384 KB Output is correct
3 Correct 66 ms 384 KB Output is correct
4 Correct 66 ms 384 KB Output is correct
5 Correct 66 ms 504 KB Output is correct
6 Correct 67 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 66 ms 504 KB Output is correct
2 Correct 65 ms 384 KB Output is correct
3 Correct 66 ms 384 KB Output is correct
4 Correct 66 ms 384 KB Output is correct
5 Correct 66 ms 504 KB Output is correct
6 Correct 67 ms 384 KB Output is correct
7 Correct 66 ms 384 KB Output is correct
8 Runtime error 68 ms 632 KB Execution killed with signal 11
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 66 ms 632 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 66 ms 504 KB Output is correct
2 Correct 65 ms 384 KB Output is correct
3 Correct 66 ms 384 KB Output is correct
4 Correct 66 ms 384 KB Output is correct
5 Correct 66 ms 504 KB Output is correct
6 Correct 67 ms 384 KB Output is correct
7 Correct 66 ms 384 KB Output is correct
8 Runtime error 68 ms 632 KB Execution killed with signal 11
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 67 ms 632 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 66 ms 504 KB Output is correct
2 Correct 65 ms 384 KB Output is correct
3 Correct 66 ms 384 KB Output is correct
4 Correct 66 ms 384 KB Output is correct
5 Correct 66 ms 504 KB Output is correct
6 Correct 67 ms 384 KB Output is correct
7 Correct 66 ms 384 KB Output is correct
8 Runtime error 68 ms 632 KB Execution killed with signal 11
9 Halted 0 ms 0 KB -