# Contest - 5 Hints to the Problems [OFFICIAL]

Hey,
We are yet to post it as it is work in progress. We will post it soon.

In problem 10 as A0,A1,…,An-1 are pairwise distinct ,but in Hint5 the numbers p1p3, p1p2, p2p3 are repeating , so I feel this is wrong, can someone please explain where I have misunderstood the Hint5

In the FIBEASY question, i think the hint for pow(2,floor(log2(N))) has some issues.
My approach : CodeChef: Practical coding for everyone
This fails in the second subtask.

Using bitwise shift gives an AC.
https://www.codechef.com/viewsolution/33177709

1 Like

Question: FIBEASY
Query : I’m getting NZEC despite getting the code to work correctly (on my system) (I took the help of the hints, and I’m pretty sure it’s correct)

So, can anyone pls see my code and maybe tell me what’s wrong?

Here’s the link : CodeChef: Practical coding for everyone

Thanks for pointing out. Updated.

@real_god Added one more hint to the problem. That will help you. Also, your code is failing for large values of N, as for those X will be large, so you should use either the observation mentioned in the Hint \space 5 or use Matrix Exponentiation

1 Like

In CHMOD there could be more than one segment of a kind with same left and right value. what to do in that case?

for ex. if 1567819567 is the array and
if left is 1 and right is 7 then there are more than 1 segment. what to do then?

Yes I got the same issue.

use pow( 2,floor ( log2 ( (double) N) ) )
This got my issue sorted

Hello,
I am Solving chef and squares,
Here is my Link to my solution: CodeChef: Practical coding for everyone

My approach was:
The perfect squares are 1,4,9,16,25,36,49,… and so on. And difference b/w these squares is 3,5,7,9,11,13,15… and so on. So I got to knew that N must be odd in-order to solve as difference are odd. After that calculated the sum of odd series and got the first term, later subtracted with N in order to get other term.
a^2 - b^2 = N
a^2 = N + b^2( N must be odd in-order to reach to a^2 as seen in sequence of differences).
Reason for calculating the odd series sum is:-
For example if N = 7
(3,5,7,9,11,…) sequence of difference of squares.
a^2 = 7 + b^2
and since b^2 is sum of previous terms we can get a link by backtracking.
a^2 = 16, b^2 = 9
16 = 9 + 7
9 = 5 + c^2
c^2 = 3 + d^2
d^2 = 1 + 0

So we wind by back tracking we get
16 = 9 + 7
9 = 5 +4
4 = 3 + 1
1 = 1 + 0

N = 7 (4 term in odd series) and did a = N*N and subtracted it N to get b.
a = 4 * 4
b = 16 - 7 (a - n)

which is sum of odd series so that’s why I calculated the sum of odd series. And later on found the term and calculated the sum based on term. and subtracted with N in-order to get other term(required term) for solution. But I don’t know where it is failing. Can you tell where am I failing please.

2 Likes

i think pow() function doesn’t work for type long long int

Whats wrong with this solution CodeChef: Practical coding for everyone in question Chef and Semiprimes

hy still getting wa in second subtask. can you please tell me what’s wrong. link to my submission is:- CodeChef: Practical coding for everyone

Hey I tried Chef and semi primes getting WA
https://www.codechef.com/viewsolution/34637926
Can someone help??

Resolved. I missed the fact that semi prime should be product of 2 primes

I am trying to solve the KPrime question in following way, can anyone please tell whats wrong in this
https://www.codechef.com/viewsolution/35583569

I removed vector since we are just interested in count, thus maintaing a vector only and still getting WA CodeChef: Practical coding for everyone

Thanks in advance.

Got the error, thanks.

Hey
Using Matrix exponentiation gives me TLE in FIBEASY.
Solution:- CodeChef: Practical coding for everyone

Hey
Using Matrix exponentiation gives me TLE in FIBEASY.
Solution:- CodeChef: Practical coding for everyone