CodeChef: Practical coding for everyone (the link of the code)
CodeChef: Practical coding for everyone (this is the problem)
and the code above is the logic I have written
I tried following the logic in the link :
binary
and the 131071 number comes using this code
A Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions.
while submitting in codechef, I am getting a SIGSEGV error, what is the mistake and how do I fix it??
shim98
March 16, 2020, 4:31pm
2
Please either format your code or (better!) link to your submission - the forum software has mangled it and it won’t compile!
1 Like
Your solution is O(nq) which will most definitely TLE. The runtime error is because A_i<10^8 where as you have only precomputed for A_i<131072 .
To solve it in O(n+q) refer to
PROBLEM LINK:
Practice
Div-2 Contest
Author: Saurabh Yadav
Tester: Suchan Park
Editorialist: William Lin
DIFFICULTY:
Simple
PREREQUISITES:
Bits, Basic Math
PROBLEM:
You are given an array A and you need to answer Q independent queries. For each query, you are given an integer P. You need to first output the number of i such that A_i \oplus P has an even number of set bits in its binary representation and then output the number of i such that A_i \oplus P has an odd number of set bits in i…
1 Like