marcha4:I am getting wrong answer though I checked all the corner cases this is my code

And what about

10 10

Your code prints

1000000000 0000000000

but correct output is

1000000000 1000000000

@betlista isn’t 1<=k<=9?
I too am getting a WA.

You are correct this input is not valid.

@betlista could u help me with this.


Just change the data type from double to long double and use log10l()

for better precision in the firstkdigit() function.

Here is the corrected code.


Here is the corrected code,

You had to use long long datatype for the arguments and operations in the LastKDigitsModularExponetiation() function.


@jaskaran_1 … there is an error of 1 in your ans…
for 8 8 your’s showing…
16777215 16777216
and mine
16777216 16777216
do check this :slight_smile:


@deepankarak I used long double and log10l() for my approach
Still getting WA at 0.64 here is my solution …Thanx in advance

jay see input #3…!!!

typecast using long long instead of int!!!

@Kunal361 still WA :frowning:

Thanks @deepankarak.What is log10l?

@jaskaran_1 yeah!!Thanx Finally!!

log10l() is same as log10() just that its return type is long double