is this problem has time complexity of o((2^n)logn)
Time complexity
It is for single testcase. If there are multiple testcases just multiply the number of testcases with it.
if n is 10^18 as in the question in not so easy math how it can be efficient
Here, n is not input which you are taking. n is the number of primes from 1 to 20.