https://www.codechef.com/viewsolution/29849687
I used binary exponentiation to compute 2^n
your power function is wrong
long long int modpower(long long int b,long long int po, long long int p){
long long int ans=1;
while(po){
if(po%2){
ans*=b;
ans%=p;
}
b*=b;
b%=p;
po/=2;
}
return ans;
}
It returns b^{po} mod p
Here’s my exponentiation function template
in one line:
inline ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
That doesn’t look like one line to me
ok…a bit forced I know. By the way…your template have a problem. What’s the output for this?
b= 1e18
po =10
p=1e9+7
I do b%p before putting it in so…
Also I just checked, he solved the question 19 hours ago
Never mind the test cases are visible now.
Thanks for pointing out everyone i realised that i made a mistake after some time in my power function
i was reading, not an easy cake. I coud see your code failed in this testcase for example
7
20 55 81 6 22 50 93
I forgot to insert 0th element in map.
And still it passes pretests as well as ~20 test cases
Thanks