This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<stdio.h>
long long dy[100100];
long long m = 1000000007;
int main() {
long long n, k;
scanf("%lld%lld", &n, &k);
dy[0] = 1;
long long sum = 0;
long long p = 0;
for (int i = 0; i < n; i++) {
dy[i + 1] = (dy[i] * k)%m;
p += sum;
p %= m;
dy[i + 1] += p;
dy[i + 1] % m;
sum += dy[i + 1];
sum %= m;
}
printf("%lld", dy[n]);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |