problem url PRMDIV Problem - CodeChef
Can anyone help and chk my solution for above problem I am getting only one input test incorrect and rest all are correct can anyone chk my code and help me??
solution link: CodeChef: Practical coding for everyone
freq is integer array multiplying 2 of them might cause overflow.
changed it to long freq and got correct but I didn’t got your point if you could elaborate how freq would get overflow if my freq count will always be less than 1000000 and my variable count which multiplies freq is already long.
Read type conversion in JAVA and C++. First,
freq[i] is int. Intermediate-Product of 2 int is stored in int. Overflow happens. Then this overflowed result stored in count.