Problem:


Score : 200 points

Problem Statement

There are N balls placed in a row.
AtCoDeer the deer is painting each of these in one of the K colors of his paint cans.
For aesthetic reasons, any two adjacent balls must be painted in different colors.

Find the number of the possible ways to paint the balls.

Constraints

1≦N≦1000

2≦K≦1000

The correct answer is at most 2^{31}-1.

Input

The input is given from Standard Input in the following format:

N K

Output

Print the number of the possible ways to paint the balls.

Sample Input 1

2 2

Sample Output 1

2

We will denote the colors by 0 and 1. There are two possible ways: we can either paint the left ball in color 0 and the right ball in color 1, or paint the left in color 1 and the right in color 0.

Sample Input 2

1 10

Sample Output 2

10

Since there is only one ball, we can use any of the ten colors to paint it. Thus, the answer is ten.



Sample input:
2 2


Sample output:
2

Submission status: Accepted

Solution code:
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(1000000)


# Debug output
def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))


# Binary converter
def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]


def gcd(n, m):
    if n % m == 0:
        return m
    else:
        return gcd(m, n % m)


def gcd_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = gcd(v, L[i])

    return v


def lcm(n, m):
    return (n * m) // gcd(n, m)


def lcm_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = lcm(v, L[i])

    return v


# Width First Search (+ Distance)
def wfs_d(D, N, K):
    """
    D: 隣接行列(距離付き)
    N: ノード数
    K: 始点ノード
    """

    dfk = [-1] * (N + 1)
    dfk[K] = 0

    cps = [(K, 0)]
    r = [False] * (N + 1)
    r[K] = True
    while len(cps) != 0:
        n_cps = []
        for cp, cd in cps:
            for i, dfcp in enumerate(D[cp]):
                if dfcp != -1 and not r[i]:
                    dfk[i] = cd + dfcp
                    n_cps.append((i, cd + dfcp))
                    r[i] = True

        cps = n_cps[:]

    return dfk


# Depth First Search (+Distance)
def dfs_d(v, pre, dist):
    """
    v:  現在のノード
    pre: １つ前のノード
    dist: 現在の距離

    以下は別途用意する
    D: 隣接リスト(行列ではない)
    D_dfs_d: dfs_d関数で用いる，始点ノードから見た距離リスト
    """

    global D
    global D_dfs_d

    D_dfs_d[v] = dist

    for next_v, d in D[v]:
        if next_v != pre:
            dfs_d(next_v, v, dist + d)

    return


def sigma(N):
    ans = 0
    for i in range(1, N + 1):
        ans += i
    return ans


class Combination:
    def __init__(self, n, mod):

        g1 = [1, 1]
        g2 = [1, 1]
        inverse = [0, 1]
        for i in range(2, n + 1):
            g1.append((g1[-1] * i) % mod)
            inverse.append((-inverse[mod % i] * (mod // i)) % mod)
            g2.append((g2[-1] * inverse[-1]) % mod)
        self.MOD = mod
        self.N = n
        self.g1 = g1
        self.g2 = g2
        self.inverse = inverse

    def __call__(self, n, r):
        if (r < 0 or r > n):
            return 0
        r = min(r, n - r)
        return self.g1[n] * self.g2[r] * self.g2[n - r] % self.MOD


# --------------------------------------------

dp = None


def main():
    N, K = li_input()

    ans = 1

    for i in range(N):
        if i == 0:
            ans *= K
        else:
            ans *= (K - 1)

    print(ans)


main()

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
ans = k
for i in range(n-1):
    ans *= (k-1)

print(ans)

Submission status: Accepted

Solution code:
N,K=[int(i) for i in input().split()]

print(K*(K-1)**(N-1))

Submission status: Accepted

Solution code:
n,k=map(int, input().split())

ret = k
for i in range(n-1):
    ret *= k-1

print(ret)

Submission status: Accepted

Solution code:
N , K = map(int, input().split())
print((K-1)**(N-1) *K)

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
 
print(K *  (K - 1)**(N - 1))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())

n =  (K - 1)**(N - 1)
print(K * n)

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
balls = []
pattern = 1
for i in range(n):
    if i == 0:
        pattern *= k
    else:
        pattern *= (k-1)
print(pattern)

Submission status: Accepted

Solution code:
ball,color = map(int,input().split())
total = 1
total *= color
if ball > 1:
    for i in range(ball-1):
        total *= color-1
print(total)

Submission status: Accepted

Solution code:
#-*-coding:utf-8-*-

def main():
    n, k = map(int, input().split())
    ans = k * (k - 1) ** (n - 1)
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N,K = [int(x) for x in input().split()]

n = K
for _ in range(N-1):
    n *= (K-1)
print(n)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sat Aug 11 14:36:03 2018

@author: maezawa
"""

n, k = list(map(int, input().split()))
print(k*(k-1)**(n-1))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
result = K
for i in range(N-1) :
    result = result * (K -1)
print(result)

Submission status: Accepted

Solution code:
n, k = map(int, input().split(" "))

print(k * (k-1)**(n-1))

Submission status: Accepted

Solution code:
N, K = map(int,input().split())
print((K-1)**(N-1) * K)

Submission status: Accepted

Solution code:
a, b=map(int, input().split())

ans=b

for i in range(a-1):
  ans*=(b-1)

print(ans)

Submission status: Accepted

Solution code:
N,K=list(map(int,input().split()))
print(K*((K-1)**(N-1)))

Submission status: Accepted

Solution code:
N, K = map(int,input().split())
print(K * (K -1) ** (N  - 1))

Submission status: Accepted

Solution code:
n, k = [int(_) for _ in input().split(' ')]
print(k * (k - 1) ** (n - 1))

Submission status: Accepted

Solution code:
n, k = (input().split())

n = int(n)
k = int(k)

r = k * pow(k-1, n-1)
print(r)

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
p=k*(k-1)**(n-1)
print(p)

Submission status: Accepted

Solution code:
n, k = list(map(int, input().split()))
print(k*pow(k-1, n-1))

Submission status: Accepted

Solution code:
n, k = [int(i) for i in input().split()]

if n == 1:
    print(k)
else:
    print(k * (k-1)**(n-1))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
value = K
for _ in range(N - 1):
    value *= (K - 1)
print(value)

Submission status: Accepted

Solution code:
N, K = list(map(int, input().split()))
print(K * ((K - 1) ** (N - 1)))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

n, k = map(int, input().split())
dp = [0 for _ in range(n+1)]
dp[1] = k
for i in range(2, n+1):
    dp[i] = dp[i-1] * (k-1)
print(dp[n])

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

N, K = map(int, input().split())

# 2個目以降のボールは組み合わせがひとつ減るのでK-1
print(K * ((K - 1) ** (N - 1)))

Submission status: Accepted

Solution code:
n, k = list(map(int, input().split()))

print(k * (k - 1) ** (n - 1))

Submission status: Accepted

Solution code:
[n,k]=[int(i) for i in input().split()]
a=k
if n==1:
    print(k)
else:
    for i in range(n-1):
        a=a*(k-1)
    print(a)

Submission status: Accepted

Solution code:
N,K=map(int,raw_input().split())
x = K
for i in range(N-1):
  x *= (K-1)
print x

Submission status: Accepted

Solution code:
N, K = map(int, input().split())

Ans=K

for i in range(0, N-1):
  Ans*=(K-1)

print(Ans)

Submission status: Accepted

Solution code:
n,k = [int(x) for x in input().split()]
print(k*((k-1)**(n-1)))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())

n = 1

for i in range(1, N+1):
    if i == 1:
        n = n*K
    else:
        n = n*(K-1)

print(n)

Submission status: Accepted

Solution code:
import numpy
import re
import math

def main():
	"""
	テストコード実行
	:return:
	"""
	n, k = map(int, input().split())
	print(k * (k - 1) ** (n - 1))

if __name__ == '__main__':
	main()

Submission status: Accepted

Solution code:
n, k = map(int,input().split())
print('{}'.format(k*((k-1)**(n-1))))

Submission status: Accepted

Solution code:
ball, color= map(int, input().split())
answer = color * (color -1)**(ball - 1)
print(answer)

Submission status: Accepted

Solution code:
i = input().split(' ')

N = int(i[0])
K = int(i[1])

ans = K

for i in range(N-1):
    ans *= (K-1)

print(ans)

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
print(K*max((K-1)**(N-1),1))

Submission status: Accepted

Solution code:

C = input().split()
N = int(C[0])
K = int(C[1])

print(K*pow((K-1),N-1))

Submission status: Accepted

Solution code:
a=list(map(int, input().split()))
a = a[1]*((a[1]-1)**(a[0]-1))
print(a)

Submission status: Accepted

Solution code:
N,K = input().split()
n = int(N)
k = int(K)

count = k
if(n == 1):
	print(count)
else:
	for i in range(n-1):
		count = count*(k-1)
	print(count)

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
print(K*(K - 1)**(N - 1))

Submission status: Accepted

Solution code:
N,K = (int(i) for i in input().split())

print(K*((K-1)**(N-1)))

Submission status: Accepted

Solution code:
n, k = map(int, input().split())

res = 1
for i in range(n):
    if i == 0:
        res *= k
    else:
        res = res*(k-1) if k-1 != 0 else res*1
print(res)

Submission status: Accepted

Solution code:
s=input().split()
N=int(s[0])
K=int(s[1])
print((K-1)**(N-1)*K)

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
ans=0
ans=K*(K-1)**(N-1)
print(ans)

Submission status: Accepted

Solution code:
a,b=[int(i) for i in input().split()]
print(b * (b-1)**(a-1))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
ans = 1
for i in range(N):
    if i == 0:
        ans *= K
        continue
    ans *= K-1
print(ans)

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
ans = K
ans *= (K-1)**(N-1)
print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

# AtCoder Beginner Contest
# Problem B

if __name__ == '__main__':
    n, k = list(map(int, input().split()))
    print(k * ((k - 1) ** (n - 1)))

Submission status: Accepted

Solution code:
def main():
    n, k = map(int, input().split())
    
    comb = k * (k-1) ** (n-1)
    print(comb)
    
    
if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
num = 1
for i in range(n):
    if i == 0:
        num = num * k
    else:
        num = num * (k - 1)

print(num)

Submission status: Accepted

Solution code:
N, K = map(int, raw_input().split())
ans = K
for i in range(1, N):
	ans = ans * (K-1)

print ans

Submission status: Accepted

Solution code:
n,k = map(int, input().split())
print(k * (k-1)**(n-1))

Submission status: Accepted

Solution code:
N, K = map(int, input().split(' '))
print(K * (K - 1)**(N - 1))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
ans = K
for k in range(1,N):
    ans *= (K-1)
print(ans)

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
if n >=2:
    print(k*(k-1)**(n-1))
else:
    print(k)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

N, K = map(int, input().split())
answers = []

ans = K
for i in range(N-1):
    ans *= (K-1)

print(ans)

Submission status: Accepted

Solution code:
N, K = [int(elem) for elem in input().split(' ')]

print(K * ((K - 1) ** (N - 1)))

Submission status: Accepted

Solution code:
n,k=map(int, input().split())
x=k
for i in range(1,n):
    x*=k-1
print(x)

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
ans = k*pow(k-1,n-1)
print(ans)

Submission status: Accepted

Solution code:
N,K = map(int,input().split())

ans = 1
for i in range(N):
    if i==0: ans *= K
    else: ans *= (K-1)
        
print(ans)

Submission status: Accepted

Solution code:
n,k = map(int, input().split(" "))
ans = k
for i in range(n-1):
  ans = ans * (k-1)
print(ans)

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
Ans = K
for i in range(1,N):
    Ans *= (K-1)
print(Ans)

Submission status: Accepted

Solution code:
n, k = map(int,input().split())
ans = k
for i in range(n-1):
    ans *= k-1
print(ans)

Submission status: Accepted

Solution code:
n, k = list(map(int,input().split()))

print(k*(k-1)**(n-1))

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
ans = K * (K - 1) ** (N - 1)
print(ans)

Submission status: Accepted

Solution code:
N, K = map(int, input().split())

if N == 1:
    print(K)
else:
    p = K
    for _ in range(N  - 1):
        p *= (K - 1)
    print(p)

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
if n == 1:
  print(k)
else:
  print(k*(k-1)**(n-1))

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
S=K
for i in range(N-1):
    S=S*(K-1)
print(S)

Submission status: Accepted

Solution code:
n,k = (int(i) for i in input().split())
print(k*((k-1)**(n-1)))

Submission status: Accepted

Solution code:
# ABC 046 B
N, K = map(int, input().split())
print(K * (K-1)**(N-1))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

N, K = map(int, input().split())
result = 1
for i in range(N):
    if i > 0:
        result *= K - 1
    else:
        result *= K
print(result)

Submission status: Accepted

Solution code:
[n, k] = [int(x) for x in input().split()]
print(k * (k - 1) ** (n - 1))

Submission status: Accepted

Solution code:
N, K = tuple(map(int ,input().split(' ')))
 
print( K * int(pow(float(K - 1), float(N - 1))) )

Submission status: Accepted

Solution code:
n, k = list(map(int, input().split()))
combinations = k
for _ in range(1, n):
    combinations *= k - 1
print(combinations)

Submission status: Accepted

Solution code:
N, K = [int(n) for n in input().split()]

V = K * (K - 1) ** (N - 1)

print(V)

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
if n == 1:
    print(k)
else:
    print(k * (k-1)**(n-1))

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
print((k - 1) ** (n - 1) * k)

Submission status: Accepted

Solution code:
n, k = map(int, input().split()); print(k*(k-1)**(n-1))

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
ans=K
for i in range(N-1):
  ans*=(K-1)
print(ans)

Submission status: Accepted

Solution code:
def main():
    N, K = map(int, input().split())

    ans = editorial(N, K)
    print(ans)


def editorial(N, K):
    """
    一番左の塗り方: K通り
    残りN-1個
        上記隣: 上記以外のK-1通り
        上記隣: 上記以外のK-1通り(一番左に塗った色復帰)
    """
    return K * (K-1) ** (N-1)


def WA(N, K):
    if N == 1:
        return K


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N,K=map(int, input().split())
 
T=K
for i in range(N-1):
  T*=(K-1)  
  
print(T)

Submission status: Accepted

Solution code:
n, k = map(int, input().split())

ans = k
for _ in range(1, n):
    ans *= (k - 1)

print(ans)

Submission status: Accepted

Solution code:
N,K = [int(i) for i in input().split()]
ans=1
for i in range(1,N+1):
  if i==1:
    ans *= K
  else:
    ans *= K-1
print(ans)

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
ans = 1
ans *= m
for i in range(n-1):
    ans *= m-1
print(ans)

Submission status: Accepted

Solution code:
N,K=map(int,input().split());print(K*(K-1)**(N-1))

Submission status: Accepted

Solution code:
N, K = map(int,input().split())
print(K * (K-1) ** (N-1))

Submission status: Accepted

Solution code:
n, k = [int(x) for x in input().split()]
print(k * (k - 1)**(n - 1))

Submission status: Accepted

Solution code:

n,k=map(int, input().split())

res = k * (k-1)**(n-1)

print(res)

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
if n==1:
    print(k)
else:
    ans=k
    for i in range(n-1):
        ans*=(k-1)
    print(ans)

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
'''
隣り合うボールは同じ色になってはいけない
= 隣り合わなければ同じでもよい

1番目の色はk通り
2番目の色はk-1通りだが
3番目の色もk-1通りとなる(1番目の色がまた使えるので)
'''
print(k*(k-1)**(n-1))

Submission status: Accepted

Solution code:
nums = list(map(int, input().split()))
n = nums[0]
k = nums[1]
ans = k*((k-1)**(n-1))
print(ans)

Submission status: Accepted

Solution code:
N,K=map(int,raw_input().split())

ans=1
for i in range(N):
	if i==0:
		ans*=K
	else:
		ans*=(K-1)
print ans

Submission status: Accepted

Solution code:
n, c = map(int, input().split())
choice = c - 1
ans = choice**(n - 1) * c
print(ans)

Submission status: Accepted

Solution code:
n, k = list(map(int, input().split()))

ans = k
for i in range(n-1):
    ans *= k-1
print(ans)

Submission status: Accepted

Solution code:
import math
N, K = [int(n) for n in input().split()]

res = 1
res *= K
res *= math.pow(K-1, N-1)
print(int(res))

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
print(k * ((k - 1)) ** (n -1))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())

print( K * ((K-1) ** (N-1)) )

Submission status: Accepted

Solution code:
input_line = map(int,raw_input().split(" "))
N = input_line[0]
K = input_line[1]

A = K * pow(K-1,N-1)

print A

Submission status: Accepted

Solution code:
from collections import defaultdict


def main():
    N, K = map(int, input().split())
    ans = K
    for _ in range(N - 1):
        ans *= (K - 1)
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N, K = list(map(int, input().split()))

print(K*(K-1)**(N-1))

Submission status: Accepted

Solution code:
n, k = map(int, input().split())

ans = k * ((k-1) ** (n-1))

print(ans)

Submission status: Accepted

Solution code:
import math
n,k=map(int,input().split())
c=k*pow(k-1,n-1)
print(c)

Submission status: Accepted

Solution code:
def ri(): return int(input())
def rli(): return list(map(int, input().split()))
def ris(): return list(input())
def pli(): return "".join(list(map(str, ans)))


N, K = rli()

print(K*pow(K-1, N-1))

Submission status: Accepted

Solution code:
N,K = map(int, raw_input().split())
c = K
for i in range(N-1):
    c *= (K-1)
print c

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
case = 1
for i in range(n):
    if i == 0:
        case *= k
    else:
        case *= k-1
    
print(case)

Submission status: Accepted

Solution code:
N, K = [int(i) for i in input().split()]

ans = K

for i in range(N-1):
    ans *= K - 1

print(ans)

Submission status: Accepted

Solution code:
N, K = map(int, raw_input().split())
ans = K
for i in range(1, N):
    ans *= K-1
print ans

Submission status: Accepted

Solution code:
n,k = map(int, input().split())

print(k * (k-1)**(n-1))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
print( K * (( K - 1 ) **( N - 1 )))

Submission status: Accepted

Solution code:
n,k = map(int, raw_input().split())
print k * ((k-1) ** (n-1))

Submission status: Accepted

Solution code:
N,K = [int(i) for i in input().split()]
print((K-1)**(N-1)*K)

Submission status: Accepted

Solution code:
n,k=map(int,raw_input().split())
print k*((k-1)**(n-1))

Submission status: Accepted

Solution code:

n,k = map(int,input().split())
ans = k
for i in range(n-1):
    ans *= (k-1)
print(ans)

Submission status: Accepted

Solution code:
import sys

def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
            return None

def solve():
    N, K = map(int, input().split())
    ans = 1

    for i in range(N):
        if i == 0:
            ans *= K
        else:
            ans *= (K - 1)

    print(ans)


if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
ans = k * (k - 1) ** (n - 1)
print(ans)

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
if n==1: print(k)
else: print((k-1)**(n-1)*k)

Submission status: Accepted

Solution code:
# -*- coding:utf-8 -*-
N,K = map(int,input().split())
ans = 0
for tmp in range (N):
    if tmp == 0:
        ans += K
    else:
        ans *= K - 1
print(ans)

Submission status: Accepted

Solution code:
n, k = list(map(int, input().split()))
print(k * (k - 1) ** (n - 1))

Submission status: Accepted

Solution code:
n,k = map(int,raw_input().split())
print k * (k-1) ** (n-1)

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
ans = K*(K-1)**(N-1)
print(ans)

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
ans = K*(K-1)**(N-1)
print(ans)

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7


def main():
    n,k = list(map(int, input().split()))
    r = k
    for _ in range(1,n):
        r *= k-1
    return r


print(main())

Submission status: Accepted

Solution code:
N, K = map(int, raw_input().split())
print K * (K - 1) ** (N - 1)

Submission status: Accepted

Solution code:
NK=input().split(" ")
N=int(NK[0])
K=int(NK[1])
print(K*(K-1)**(N-1))

Submission status: Accepted

Solution code:
def main():
    n, k = map(int, input().split())
    ans = k
    for i in range(n - 1):
        ans *= (k - 1)
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N,K = [int(x) for x in raw_input().split()]

print K * (K-1)**(N-1)

Submission status: Accepted

Solution code:
n, k = map(int, input().split())

ans = k
for _ in range(n-1):
    ans *= (k-1)

print(ans)

Submission status: Accepted

Solution code:
nk = map(int,raw_input().split())
ans = nk[1]
for i in range(0, nk[0]):
    if i == 0:
        pass
    else:
        ans *= (nk[1]-1)

print ans

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
ways = k * ((k - 1) ** (n - 1))
print(ways)

Submission status: Accepted

Solution code:
#coding:utf-8
N,K=list(map(int,input().split()))
print(K*(K-1)**(N-1))

Submission status: Accepted

Solution code:
def main():
    n, k = map(int, input().split())
    ans = k
    for i in range(1, n):
        ans *= (k - 1)
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n,k = map(int,input().split())

ans = k
for i in range(n-1):
    ans *= k-1
print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

N, K = list(map(int, input().split()))

ans = K * (K - 1)**(N - 1)

print(int(ans))

Submission status: Accepted

Solution code:
N, K = map(int, raw_input().split())
# N, K = 10, 8
 
print K * (K-1) ** (N-1)

Submission status: Accepted

Solution code:

import math as mth

n,c = map(int,input().split())

print(int(c*mth.pow(c-1,n-1)) )

Submission status: Accepted

Solution code:
N,K=map(int,raw_input().split())

result=K
for i in range(N-1):
    result=result*(K-1)

print result

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
m = k
for i in range(n-1):
    m = m * (k - 1)
print(m)

Submission status: Accepted

Solution code:
inp = [int(x) for x in raw_input().strip().split(' ')]
print inp[1] * (inp[1] - 1) ** (inp[0] - 1)

Submission status: Accepted

Solution code:
N,K = map(int,raw_input().split(" "))
ans = 1
for i in range(N-1):
    ans *= K-1
print ans *K

Submission status: Accepted

Solution code:
i,j = map(int, raw_input().split())
print (~-j)**~-i*j

Submission status: Accepted

Solution code:
i = map(int, raw_input().split())
print pow(i[1]-1, i[0]-1)*i[1]

Submission status: Accepted

Solution code:
n, k=map(int, input().split())

ans=k*(k-1)**(n-1)

print(ans)

Submission status: Accepted

Solution code:
N=input().split()
print(int(N[1])*(int(N[1])-1)**(int(N[0])-1))

Submission status: Accepted

Solution code:
n, k = map(int, raw_input().split())
r = k * (k - 1) ** (n - 1)
print r

Submission status: Accepted

Solution code:
list = input().split()
a = (int(list[0])-1)
b = int(list[1])-1
print(pow(b,a)*int(list[1]))

Submission status: Accepted

Solution code:
N, K = list(map(int, input().split()))

ans=K
for i in range(1,N):
    ans*=(K-1)
    
print(ans)

Submission status: Accepted

Solution code:
def main():
	inpt = raw_input().split()
	n = int(inpt[0])
	k = int(inpt[1])
	ans = k
	for i in range(1, n):
		ans *= k - 1
	print ans
	
main()

Submission status: Accepted

Solution code:
input = raw_input()
l = input.split(" ")
a = map(int,l)
N = a[0]
K = a[1]

color = range(0, K)

ans = K
for i in range(1, N):
    ans *= K - 1
print ans

Submission status: Accepted

Solution code:
import sys

n, k = map(int, sys.stdin.readline().split())
print k * (k-1) ** (n-1)

Submission status: Accepted

Solution code:
try:
    nk = map(int, raw_input().split(" "))
    N = nk[0]
    K = nk[1]
    print K*(K-1)**(N-1)
except EOFError:
    pass

Submission status: Accepted

Solution code:
# B
N, K = [int(i) for i in input().split()]
print(K*(K-1)**(N-1))

Submission status: Accepted

Solution code:
n, k = map(int,input().split())
print(int(k * (k-1) ** (n - 1)))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
N, K = map(int, input().split())

ans = K*(K-1)**(N-1)
print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

n, k = map(int, raw_input().split())

print k * (k-1) ** (n-1)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
n, k = map(int, raw_input().split())

print k * (k - 1) ** (n - 1)

Submission status: Accepted

Solution code:
N, K = map(int, raw_input().split())
print K * (K - 1) ** (N - 1)

Submission status: Accepted

Solution code:
n,k = [int(x) for x in input().split(" ")]
res = k
for i in range(1,n):
    res *=(k - 1)
print(res)

Submission status: Accepted

Solution code:
elems = input().split()
n, k = int(elems[0]), int(elems[1])

print(k * (k-1)**(n-1))

Submission status: Accepted

Solution code:
N, K = map(int, raw_input().split())

ans = K
for i in xrange(1, N):
    ans *= K-1

print ans

Submission status: Accepted

Solution code:
NK = list(map(int,input().split(" ")))
out = NK[1]
for i in range(NK[0]-1):
    out = out * (NK[1]-1)
print(out)

Submission status: Accepted

Solution code:
N,K = map(int,input().split(' '))
print((K-1)**(N-1)*K)

Submission status: Accepted

Solution code:
n,k = map(int,raw_input().split(" "))
print k* ((k-1)**(n-1) if n != 1 else 1)

Submission status: Accepted

Solution code:
n, k =map(int, input().split())
print(k*((k-1)**(n-1)))

Submission status: Accepted

Solution code:
n, m = map(int, input().split())

ans = m*((m-1)**(n-1))

print(ans)

Submission status: Accepted

Solution code:
from sys import stdin
n,k = map(int,stdin.readline().split())
print k * ((k-1)**(n-1))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
result = K
for i in range(N - 1):
    result *= (K - 1)

print(result)

Submission status: Accepted

Solution code:
n, k = map(int, raw_input().split())
print k * ((k - 1) ** (n - 1))

Submission status: Accepted

Solution code:
#ABC046B

n,k=map(int,raw_input().split())
print k*((k-1)**(n-1))

Submission status: Accepted

Solution code:
N, K = input().split() 
N = int(N)             
K = int(K)             
ans = 0                
ans = K*((K-1)**(N-1)) 
print(ans)

Submission status: Accepted

Solution code:
# coding: utf-8

inp = input().split()

n = int(inp[0])
k = int(inp[1])

print( ((k-1) ** (n-1) * k ))

Submission status: Accepted

Solution code:
import math
n, m = list(map(int, input().split()))
print(m*pow(m-1,n-1))

Submission status: Accepted

Solution code:
n,k=map(int,raw_input().split())
print(k*(k-1)**(n-1))

Submission status: Accepted

Solution code:
n, k = map(int, raw_input().split())
print(k * (k-1)**(n-1))

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    n, k = [int(x) for x in input().split()]
    ans = k * pow((k-1),n-1)
    print(ans)

Submission status: Accepted

Solution code:
n,k=map(int,raw_input().split())
print(k-1)**~-n*k

Submission status: Accepted

Solution code:
n, k = map(int, input(). split())

print(k * (k - 1) ** (n - 1))

Submission status: Accepted

Solution code:
data = input().split()
ball = int(data[0])
color = int(data[1])
print(color * ((color - 1) ** (ball - 1)))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
ans = 1
flg = True
for i in range(N):
    if flg:
        ans *= K
    else:
        ans *= (K - 1)
    flg = False
print(ans)

Submission status: Accepted

Solution code:
N, K = map(int,input().split())

print( K * (K - 1) ** (N-1))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys,copy,math,heapq,itertools as it,fractions,re,bisect,collections as coll

N, K = map(int, raw_input().split())
print K*(K-1)**(N-1)

Submission status: Accepted

Solution code:
l=map(int, raw_input().split())

ans=l[1]*((l[1]-1)**(l[0]-1))

print ans

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
ans = k
for i in range(n - 1):
    ans *= (k - 1)
print(ans)

Submission status: Accepted

Solution code:
n,k = map(int, input().split())
 
print(k * ((k-1) ** (n-1)))

Submission status: Accepted

Solution code:
n, k = map(int, input().split())


print(k*(k-1)**(n-1))

Submission status: Accepted

Solution code:
result = 0
N, K = map(int, input().split())
if N == 1:
    result = K
else:
    result = K
    for i in range(N-1):
        result = result * (K - 1)
print(result)

Submission status: Accepted

Solution code:
n = list(map(int, input().split()))
x = n[1] * ((n[1] - 1) ** (n[0] - 1))
print(x)

Submission status: Accepted

Solution code:
import sys

n, k = map(int, raw_input().split())
ans = k # first                                                                                                 
if n == 1 and k == 1:
    print ans
    sys.exit()
for i in range(n-1):
    ans *= k-1
print ans

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

nums = list(map(int, input().split()))
N = nums[0]
K = nums[1]

a = K * ((K-1) ** (N-1))
print(a)

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
i = k
n -= 1
k -= 1
while n > 0:
    i = i * k
    n -= 1
print(str(i))

Submission status: Accepted

Solution code:
from sys import stdin

n, k = (int(x) for x in stdin.readline().split())

print(k * ((k-1) ** (n-1)))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-


n, k = map(int, input().split())


def main(n, k):
    if n == 1:
        return n * k
    else:
        i = 1
        for _ in range(n):
            if i == 1:
                i *= k
            else:
                i *= (k - 1)
        return i

print(main(n, k))
# print(main(10, 8))

Submission status: Accepted

Solution code:
a = list(map(int, input().split()))
print(a[1] * ((a[1] - 1)**(a[0] - 1)))

Submission status: Accepted

Solution code:
line = input().split()
l = list(map(int, line))
n = l[0]
k = l[1]

ans = k * pow(k-1, n-1)
print (ans)

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
print(K * (K -1) ** (N -1) )

Submission status: Accepted

Solution code:
n, k = list(map(int, input().split()))
print(k * pow(k - 1, n - 1))

Submission status: Accepted

Solution code:
#coding=UTF-8

mojir=input()
hyo=mojir.split(' ')

N=int(hyo[0])
K=int(hyo[1])

#短絡的にやります
ans=1
for idx in range(0,N,1):
    iro = K-1 if idx != 0 else K
    ans=ans*iro

print(ans)

Submission status: Accepted

Solution code:
N, K = [int(i) for i in input().split()]
print(K*((K-1)**(N-1)))