We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Little Gaurav and Sequence
Little Gaurav and Sequence
Sort by
recency
|
6 Discussions
|
Please Login in order to post a comment
This is a pure math problem. You don't need to do any coding! Approach this like a math problem and solve it on paper then put your result in code.
My code:
JavaScript solution:
int main(){ long long int t,n,p; scanf("%lld",&t); while(t--){ scanf("%lld",&n); if(n%2!=0){ printf("0\n"); }else if(n==2){ printf("6\n"); } else{ p=log(n)/log(2); printf("%lld\n",(p*6)%10); } } }
O(1) :)
I am not sure if this problem is correct. The output is not mine. Even when I deleted all the print (I am using Python), the outputs never change.