Ishtiaque and the Rabbit

Mr Ishtiaque is in trouble. A few months ago, he bought 2 rabbits. He wanted to have two pet rabbits…

Click here to read the complete problem statement.


If you need help solving this problem, mention your approach and ask specific questions. Please avoid sharing your code and asking the Community to figure out “what’s wrong”.

I think the CPU limit should be increased for python.

Datasets are weak I think. O(n*t) solutions are passing. According to the constraints it shouldn’t happen. Thank you. <3

You want better algorithms than O(n) ?
I donot think that the fact that linear solutions are accepted should cause any problem though.

I wanted to say that, the main solve is O(n) and as there are test cases, So the full solve becomes O(n*t). For the worst case, can it work in 1 second?

@hjr265 if you have time can you see that once?

Increase the time limit for python.
Here is my code: [It’s getting cle in last case]

num_test = int(input())
for i in range(num_test):
    a, b, c = map(int, input().split())
    num_rabbit = a
    for j in range(1, c):
        num_rabbit += a * b**j
    print(num_rabbit)

the tags of this problem may help I think!:smiley:

why it gives me “wrong answer”
i think my answer is correct

#include <stdio.h>
#include<math.h>

int main() {
    long long a, b, c, d, e, f, g;
    scanf("%lld", &a);
    for(b=0; b<a; b++){
        g=0;
        scanf("%lld %lld %lld", &c, &d, &e);
        g=(pow(d,e)-1)*c/(d-1);
        printf("%lld\n", g);
    }
	return 0;
}