# Help me in solving AOCP10 problem

### My code

``````// Update the code below to solve the problem

#include <stdio.h>

int main() {
int t;
scanf("%d", &t);
for (int i = 0; i < t; i++) {
int n,p,q;
scanf("%d", &n);
int A[n];
int count;
for (int j = 0; j < n; j++) {
scanf("%d", &A[j]);
}

for(int i=0;i<n;i++)
{
if(A[i]==(6*(i+1)+i))
{
p=p-1;
}
else if(A[i]==7*i)
{
q=q-1;
}
else
{
p=4;
q=4;
}

}
count=n+p+q;

printf("%d\n",count);
}
}

``````

Learning course: C for problem solving - 2
Problem Link: CodeChef: Practical coding for everyone

@soyelrana
In the given problem, we have to find if a holiday falls on either Sunday or Saturday and print the total number of holidays.

The logic I used here was like this;

We already have at least 8 holidays in the month. Now,

While taking A[j] as input, I am checking if it falls on a saturday or sunday. If it is equals to either [ 6,13, 20,27 ]* or [7,14,21,28], if yes, we continue in the loop, otherwise, the count of holidays is increased by +1.

Finally, we print number of holidays, denoted here by c.

You can refer to the following code to get a better understanding.

``````// Update the code below to solve the problem

#include <stdio.h>

int main() {
int t;
scanf("%d", &t);
for (int i = 0; i < t; i++) {
int n,c=8;
scanf("%d", &n);
int A[n];
for (int j = 0; j < n; j++) {
scanf("%d", &A[j]);
if( (A[j]==6)||(A[j]==13)||(A[j]==20)||(A[j]==27)||(A[j]==7)||(A[j]==14)||(A[j]==21)||(A[j]==28) )
{
continue;
}
else
{
c++;
}
}
printf("%d\n",c);
}
}

``````