Understanding this program...

Problem: http://www.codechef.com/DEC14/problems/CAPPLE
Solution:
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
#include <stdio.h>
#include<iostream>
#include<map>
using namespace std;
int main()
{
	int T,N,a,count;
	scanf("%d",&T);
	while(T--)
	{
		scanf("%d",&N);
		bool b[100005]={false};
		count=0;
		for(int i=0;i<N;i++)
		{
			scanf("%d",&a);
			if(b[a]==false)
			{
				b[a]=true;
				count++;
			}	
		}
		printf("%d\n",count);
	}	
	return 0;
}


I cant understand the bool b[100005]={false}; statement.
I tried searching this on google. And I got a whole lot of programs which use the 100005. What is that number? Why is it used? And what does the statement do?

Also what is the while(t--)? How can a quantity such as 't', ever be false?
Last edited on
There is subtask 3 in site you provided. In this subtask there may be maximum 100000 apple trees. So bool[100000] is enough. IMHO author writes 100005 on a safe side.
Thanks for that. What is while(t--)? Can a quantity resolve to false or true?
I got it. When t goes to 0 the while loop stops executing.
Topic archived. No new replies allowed.