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:
N, K = map(int, input().split())
print(K * pow(K-1, N-1))

Submission status: Accepted

Solution code:
#46
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:
# coding: utf-8

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:
a = [int(n) for n in input().split()]
if a[0]==1:
  print (a[1])
else:
  print (a[1]*(a[1]-1)**(a[0]-1))

Submission status: Accepted

Solution code:
# -*- coding utf-8 -*-
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())
ans=k
for i in range(n-1):
  ans = ans*(k-1)
print(ans)

Submission status: Accepted

Solution code:
N, K =map(int, open(0).read().split())
a = K * ((K - 1) ** (N - 1))
print(a)

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

print(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:
N,K = map(int, input().split())
print(K * (K-1) ** (N-1))

Submission status: Accepted

Solution code:
def painting_balls_with_atcodeer(N: int, K: int) -> int:
    return K * ((K-1) ** (N-1))


if __name__ == "__main__":
    N, K = map(int, input().split())
    ans = painting_balls_with_atcodeer(N, K)
    print(ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, K = MAP()
print(K*(K-1)**(N-1))

Submission status: Accepted

Solution code:
from functools import reduce

def main():
    # 初期値用:十分大きい数(100億)
    # 1e10

    # 初期値用:十分小さい数(-100億)
    # -1e10

    # 1文字のみを読み込み
    # s = input().rstrip()
    
    # スペース区切りで標準入力を配列として読み込み
    # s = input().rstrip().split(' ')

    # 1文字ずつ標準入力を文字列として読み込み
    # s = list(input().rstrip())
    
    # 位置文字ずつ標準入力を数値配列として読み込み
    X = [int(_) for _ in input().split()]
    N = X[0]
    K = X[1]
    print(K*(K-1)**(N-1))
if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

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())

print(K * pow((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())
     
a = k*((k-1)**(N-1))
     
print(a)

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
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())
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:
# -*- coding: utf-8 -*-
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())

answer = 1

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

print(answer)

Submission status: Accepted

Solution code:
#S = "2 2"
S = input()
N, K = map(int, S.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:
def main():
    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())

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()]
ans=k
for i in range(1,n ):
    ans*=(k-1)
print(ans)

Submission status: Accepted

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

print(sum)

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*(K-1)**(N-1))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b=map(int,input().split());print(b*((b-1)**(a-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:
# ABC 046 B

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

Submission status: Accepted

Solution code:
N, K = list(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 = list(map(int, input().split()))

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

Submission status: Accepted

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


def main():
    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(str(K*((K-1)**(N-1))))

Submission status: Accepted

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

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

print(pattern)

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())
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())
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:
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy
from operator import itemgetter
#以下てんぷら
def j(q):
    if q==1: print("Yes")
    else:print("No")
    exit(0)


def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")

def ip():
    return int(input())

rem = pow(10,9)+7

#n = ip()                                     #入力整数1つ
x,y= (int(i) for i in input().split())       #入力整数横2つ以上
#a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[input() for i in range(x)]    #入力セット(整数改行あり)(2/2)

#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
#こっから本文
print(y * pow(y-1,x-1))

Submission status: Accepted

Solution code:
a,b = map(int, input().split())
print(b*((b-1)**(a-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 = map(int,input().split())

ans = K * (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 = map(int, input().split())
result = 1
for i in range(N):
    if 0 == i:
        result *= K
    else:
        result *= K-1
print(result)

Submission status: Accepted

Solution code:
""" AtCoder """

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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, input().split())
print(K * (K - 1) ** (N - 1))

Submission status: Accepted

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

Submission status: Accepted

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

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

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:
import sys

def main():
	n, k = map(int, input().split(" "))

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

	print(ans)

if __name__ == "__main__":
	main()

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())
A=K*(K-1)**(N-1)
print(A)

Submission status: Accepted

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

Submission status: Accepted

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

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 = map(int,input().split())
print(K*pow(K-1,N-1))

Submission status: Accepted

Solution code:
# coding: utf-8
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:
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 = map(int, input().split())
print(k if n==1 else k*(k-1)**(n-1))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
nk = list(map(int, input().split()))
print(nk[1]*((nk[1]-1)**(nk[0]-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())

if N==1:
    print(K)
    exit(0)
else:
    print(K*((K-1)**(N-1)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
ans=k
for s in range(n-1):ans*=(k-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:
N, K = map(int, input().split())
comb = K*(K-1)**(N-1)
print(comb)

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 = [int(x) for x in 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 * (k - 1) ** (n - 1))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, k = list(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
for i in range(n-1):
    ans*=(k-1)
print(ans)

Submission status: Accepted

Solution code:
ball,color=map(int,input().split())
if color == 1 and ball ==  1:
	print(str(1))
else:
	print(str(color * ((color-1)**(ball-1))))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!usr/bin/env python3
from collections import defaultdict
import math
def LI(): return list(map(int, input().split()))
def II(): return int(input())
def LS(): return input().split()
def S(): return input()
def LIR(n): return [LI() for i in range(n)]
mod = 1000000007

#A
n,k = LI()
ans = k
for i in range(1,n):
    ans *= k-1
print(ans)
#B
"""
r,n,m = LI()
l = [2*r*math.cos(math.asin((n/2-i)/n*2)) for i in range(n+1)]
ans = 0
for i in range(1,n+m):
    a = 0 if i-m <= 0 else l[i-m]
    b = 0 if i >= n else l[i]
    ans += max(a,b)
print(ans)
"""

#C
"""
n = II()
a = LI()
print(sum(a)-n)
"""

#D
"""
s = list(S())
lis = []
sign = ["","+"]
k = 2**(len(s)-1)
d = 10-len(s)
for i in range(d):
    s.insert(0,"0")
i = 0
for a0 in range(2):
    for a1 in range(2):
        for a2 in range(2):
            for a3 in range(2):
                for a4 in range(2):
                    for a5 in range(2):
                        for a6 in range(2):
                            for a7 in range(2):
                                for a8 in range(2):
                                    if i >= k:break
                                    lis.append(s[0]+sign[a0]+s[1]+sign[a1]+s[2]+sign[a2]+s[3]+sign[a3]+s[4]+sign[a4]+s[5]+sign[a5]+s[6]+sign[a6]+s[7]+sign[a7]+s[8]+sign[a8]+s[9])
                                    i += 1
ans = 0
for i in lis:
    ans += eval(i[d:])
print(ans)
"""
#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#A
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 = list(map(int, input().strip().split()))

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

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(200000)


def input():
    return sys.stdin.readline()[:-1]


def ii(t: type = int):
    return t(input())


def il(t: type = int):
    return list(map(t, input().split()))


def imi(N: int, t: type = int):
    return [ii(t) for _ in range(N)]


def iml(N: int, t: type = int):
    return [il(t) for _ in range(N)]


def solve():
    N, K = il()
    return K * (K - 1) ** (N - 1)


if __name__ == "__main__":
    print(solve())

Submission status: Accepted

Solution code:
def execute(n, k):
    return k * (k - 1) ** (n - 1)


if __name__ == '__main__':
    n, k = map(int, input().split())
    print(execute(n, k))

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:
N,K = map(int,input().split())
ans = K * pow(K-1,N-1)
print(ans)

Submission status: Accepted

Solution code:
tmp = list((map(int, input().split())))
N = tmp[0]
K = tmp[1]

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

print(paint(N,K))

Submission status: Accepted

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

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) if N == 1 else print(K*(K-1)**(N-1))

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:
n, k = [int(x) for x in input().split()]
print(k * (k - 1) ** (n - 1))

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 = map(int,input().split())
S = K
while(1):
    if N==1:
        break
    S *= (K-1)
    N-=1
print(S)

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:
n, k = [int(i) for i in input().split()]

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b =map(int, input().split())
s = b
t = (b-1)**(a-1)
s*=t
print(s)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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:
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:
def main():
    n, k = map(int, input().split())
    res = k * ((k - 1)**(n - 1))
    print(res)


if __name__ == '__main__':
    main()

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:
import math
N ,K = map(int, input().split(" "))
print(int(K * math.pow(K-1, N-1)))

Submission status: Accepted

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

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 = [int(i) for i in input().split()]

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

print(patterns)

Submission status: Accepted

Solution code:
N, K = list(map(int, input().split()))
ans = K * (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 = ans*k
    else:
        ans = ans*(k-1)
print(ans)

Submission status: Accepted

Solution code:
n,k = map(int,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())

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

    print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

import sys

def solve(n, k):
    ans = k
    for i in range(2,n+1):
        ans *= (k-1)
    print(ans)


def readQuestion():
    ws = sys.stdin.readline().strip().split()
    n = int(ws[0])
    k = int(ws[1])
    return (n, k,)

def main():
    solve(*readQuestion())

# Uncomment before submission
main()

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
ans = 0
#最初の一つはK色から選べる
#二つ目からは(K-1)色から選ぶ
ans = K * (K-1)**(N-1)
print(ans)

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 = map( int, input().split())
print(K*pow(K-1,N-1))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,K=map(int,input().strip().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(" "))
goukei = k*(k-1)**(n-1)
print(goukei)

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:
N, K = map(int, input().split())
answer = K * ((K-1)**(N-1))
print(answer)

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:
ball, color = map(int, input().split())

print(color*(color - 1)**(ball - 1))

Submission status: Accepted

Solution code:
ball, color = map(int, input().split())

ans = color
for i in range(ball - 1):
    ans *= (color - 1)
print(ans)

Submission status: Accepted

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


def abc046_b():
    n, k = map(int, input().split())
    return k * ((k - 1) ** (n - 1))


if __name__ == '__main__':
    print(abc046_b())

Submission status: Accepted

Solution code:
a,b=map(int,input().split(" "))
print(b*(b-1)**(a-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 = map(int, input().split())
print(K * (K-1) ** (N - 1))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
## ABC 046 b
n,k = (int(_) for _ in 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 = 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())
way = K

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

print(way)

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 x in range(n-1):
    ans *= k-1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(count)

Submission status: Accepted

Solution code:
def main():
    N, K = map(int, input().split())
    res = 0
    if N == 1:
        res = K
    else:
        res = K * (K - 1) ** (N - 1)

    print(res)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
from sys import stdin


def main():
    n = next_int()
    k = next_int()
    ans = 1

    for i in range(n):
        ans *= k - (i != 0)

    print(ans)


def next_int():
    return int(next_str())


def next_str():
    result = ""
    while True:
        tmp = stdin.read(1)
        if tmp.strip() != "":
            result += tmp
        elif tmp != '\r':
            break
    return result


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
from sys import stdin

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

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

Submission status: Accepted

Solution code:
a = input().split(" ")
count = int(a[1])
for i in range(int(a[0])-1):
    count *= int(a[1]) - 1
print(count)

Submission status: Accepted

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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#! /usr/bin/python3
# AtCoDeerくんとボール色塗り / Painting Balls with AtCoDeer
"""
    1≦N≦1000
    2≦K≦1000
    答えは 2^(31)−1 以下
"""
test_mode = True

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

Submission status: Accepted

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

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*((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 = (int(i) for i in input().split())

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


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=map(int, 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:
n, k = map(int, input().split())

ans = 0

for i in range(n):
    if i == 0:
        ans = ans + k

    else:
        ans = 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:
a, b = map(int, raw_input().split())
print b * ((b - 1) ** (a - 1))

Submission status: Accepted

Solution code:
a, b = map(int, raw_input().split())
print b * ((b - 1) ** (a - 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())
answer = K * ((K-1)**(N-1))
print(answer)

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:
na = lambda: list(map(int, input().split()))
n, k = na()
ans = k
for i in range(n-1):
    ans *= (k-1)
print(ans)

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 * (k-1)**(n-1))

Submission status: Accepted

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

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:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
n, k = map(int, input().split())
if n == 2:
  print(k)
else:
  print(k*(k-1)**(n-1))

Submission status: Accepted

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

Submission status: Accepted

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