marcha4:I am getting wrong answer though I checked all the corner cases

CodeChef: Practical coding for everyone this is my code

And what about

1
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.
http://www.codechef.com/viewsolution/2295923

@jaskaran_1

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

for better precision in the firstkdigit() function.

http://ideone.com/qtEWfm

Here is the corrected code.

Edit:
@jaythegenius

Here is the corrected code,

http://ideone.com/YVaVHq

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

2 Likes

You are correct this input is not valid.

@betlista could u help me with this.

@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:

3 Likes

@deepankarak I used long double and log10l() for my approach
Still getting WA at 0.64 here is my solution
enHGS8 - Online C++ Compiler & Debugging Tool - Ideone.com …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!!

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