repl.it
C++

No description

fork
loading
Files
  • main.cpp
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include<cstdio>
#include<string>
#include<iostream>

using namespace std;

int main(){
	
	int t;
	scanf("%d", &t);
	int s = 200;
	int n;
	int seq[s+1];
	
	seq[0] = 0;
	seq[1] = 0;
	seq[2] = 1;
	int j;
	for(int i = 3; i < s; i++){
		int x = seq[i-1];
		j = i-2;
		while(j >= 0){
			if(seq[j] == x)
				break;
			j--;
		}
		if(j == -1)
			seq[i] = 0;
		else
			seq[i] = i-j-1;	
	}
	
	int q;
	int cnt;
	while(t--){
		cnt = 0;
		scanf("%d", &q);
		for(int i = 0; i < q; i++)
			if(seq[i] == seq[q-1])
				cnt++;
		printf("%d\n", cnt);
	}

	return 0;
}