Algorithm
Code Examples
#1 Code Example with C++ Programming
Code -
C++ Programming
#include <bits/stdc++.h>
using namespace std;
int const M = 1e9 + 7;
int main() {
int n, m, k;
scanf("%d %d %d", &n, &m, &k);
long long res;
if(n == k) {
res = 1;
for(int i = 0; i < (n + 1) / 2; ++i)
res *= m,
res %= M;
} else if(k > n || k == 1) {
res = 1;
for(int i = 0; i < n; ++i)
res *= m,
res %= M;
} else if(k % 2 == 0)
res = m;
else
res = m * m;
printf("%lld\n", res);
return 0;
}
Copy The Code &
Try With Live Editor
Input
1 1 1
Output
1
Demonstration
Codeforcess Solution Quantity of Strings, D. Quantity of Strings ,C,C++, Java, Js and Python ,Quantity of Strings,Codeforcess Solution