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

Submission status: Accepted

Solution code:
nums, types = map(int,input().split())

result = types * ( (types -1) ** (nums -1))
print(result)

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

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

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 *= k
    else:
        cnt *= (k - 1)
print(cnt)

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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())
count = 0
if (n == 1):
    count = k
else:
    count = (k)*((k-1)**(n-1))
        

print(count)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from copy import deepcopy
from sys import exit,setrecursionlimit
import math
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac

setrecursionlimit(1000000)


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

def zip(a):
	mae = a[0]
	ziparray = [mae]
	for i in range(1,len(a)):
		if(mae != a[i]):
			ziparray.append(a[i])
			mae = a[i]
	return ziparray

def is_prime(n):
	if n < 2: return False

	for k in range(2, int(math.sqrt(n)) + 1):
		if n % k == 0:
			return False

	return True

def list_replace(n,f,t):
	return [t if i==f else i for i in n]

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

def gcd(l):
	x = l.pop()
	y = l.pop()
	while(x%y!=0):
		z = x%y
		x = y
		y = z
	l.append(min(x,y))
	return gcd(l) if len(l) > 1 else l[0]

class Queue():
	def __init__(self):
		self.q = deque([])
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.popleft()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class Stack():
	def __init__(self):
		self.q = []
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.pop()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class graph():
	def __init__(self):
		self.graph = defaultdict(list)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
		self.graph[t].append(f)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
		self.graph[t].remove(f)
	def linked(self,f):
		return self.graph[f]

class dgraph():
	def __init__(self):
		self.graph = defaultdict(set)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
	def linked(self,f):
		return self.graph[f]

main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
bols,cols = (int(i) for i in input().split())

n = cols * pow((cols - 1), (bols - 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())
print((K * ((K - 1)**(N - 1))))

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

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

Submission status: Accepted

Solution code:
ballN, clrs = map(int, input().split())
print(clrs * ((clrs-1) ** (ballN-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:
N, K = map(int, input().split())
out = K
for _ in range(N - 1):
  out *= (K - 1)
print(out)

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

print(P)

Submission status: Accepted

Solution code:
# ABC 46, B - painting balls with at codeer
n, k = [int(el) for el in input().split(' ')]
print(k*(k-1)**(n-1))

Submission status: Accepted

Solution code:
# Painting Balls with AtCoDeer
N, K = map(int, input().split())
ans = 0
# i=0の色はK i<=1の色の選択肢はK-1
# K*(K-1)*(K-1)... N回積をとる

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

Submission status: Accepted

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

Submission status: Accepted

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


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

Submission status: Accepted

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

ans = 1

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys, math, fractions, itertools


def solve(N: int, K: int):
    print(K * (K-1)**(N-1))
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(N, K)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from collections import Counter, defaultdict
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline
from math import factorial
import bisect
import math



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





if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def solve():
    n, k = read()
    result = think(n, k)
    write(result)


def read():
    return read_int(2)


def read_int(n):
    return list(map(lambda x: int(x), read_line().split(' ')))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(n, k):
    return k * (k - 1) ** (n - 1)


def write(result):
    print(result)


if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(300000)


def solve(N: int, K: int):
    ret = K * (K - 1) ** (N - 1)
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(N, K)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
if n == 1:
    print(k)
else:
    ans = k
    k -= 1
    n -= 1
    for i in range(n):
        ans *= k
    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())
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())
ans = k * pow(k-1, n-1)
print("{}".format(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
for i in range(n - 1):
    ans *= k - 1
print(ans)

Submission status: Accepted

Solution code:
#ABC046b
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

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

Submission status: Accepted

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

import sys

sys.setrecursionlimit(10**7)

# Override `input` function because `stdin.readline()` is 10x faster than built-in `input()`
input = sys.stdin.readline


def read_h(typ=int):
    return list(map(typ, input().split()))


def read_v(n, m=1, typ=int):
    return [read_h(typ) if m > 1 else typ(input()) for _ in range(n)]


def main():
    n, k = read_h()
    print(k * (k - 1)**(n - 1))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(res)

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

Submission status: Accepted

Solution code:
a, b = map(int, input().split())
c = 1
for i in range(a):
    if i == 0:
        c *= b
    else:
        c *= (b-1)
print(c)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

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:
N, K = map(int, input().split())
ans = 1
# 1つ目
ans *= K
# 2つ目以降
ans *= (K - 1)**(N - 1)
print(ans)

Submission status: Accepted

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

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())
ans = K
if N == 1:
    print(ans)
    exit()
else:    
    for i in range(1, N):
        ans *= (K - 1)

print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# coding=utf-8
N,K=map(int,input().split())
ans=K
for i in range(N):
    if i!=0:
        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())
res = K * (K - 1)**(N-1)
print(res)

Submission status: Accepted

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

dp = [[0] * k for _ in range(n)]
for i in range(k):
  dp[0][i] = 1

for i in range(1, n):
  toAdd = sum(dp[i - 1])
  for j in range(k):
    dp[i][j] += toAdd - dp[i - 1][j]
    
print(sum(dp[-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())
print(b * (b-1)**(a-1))

Submission status: Accepted

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

ans = row[1] * (row[1]-1)**(row[0]-1)
print(ans)

Submission status: Accepted

Solution code:
from sys import stdin
N,K = [int(x) for x in stdin.readline().rstrip().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:
#!/usr/bin/env python3
#ABC46 B

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

ans = 1

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

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:
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 = 1
for i in range(N):
    if i == 0:
        ans *= K
    else:
        ans *= K - 1

print(ans)

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

for i in range(a[0]):
  if i==0:
    b*=a[1]
  else:
    b*=a[1]-1
else:
  print(b)

Submission status: Accepted

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

if __name__ == '__main__':
    main()

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

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

Submission status: Accepted

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

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:
import bisect
import heapq
import itertools
import math
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18

N, K = list(map(int, sys.stdin.readline().split()))

# 一番左の色が決まるとその右も決まる
print(pow(K - 1, N - 1) * K)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

N, K = nl()

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

print(total)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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


abc()

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

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

Submission status: Accepted

Solution code:
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000


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

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
print(m*((m-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 = k
    else:
        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())

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())
if n==1:
  print(k)
else:
  print(k*(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 = list(map(int, input().split()))

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

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:

def main(N, K):
    print(K * (K-1)**(N-1))

if __name__ == "__main__":
    N, K = [int(x) for x in input().split()]

    main(N, K)

def test1(capsys):
    inputs = [2, 2]
    out = 2
    main(*inputs)
    captured = capsys.readouterr()    
    assert captured.out == str(out) + '\n'

def test3(capsys):
    inputs = [1, 10]
    out = 10
    main(*inputs)
    captured = capsys.readouterr()    
    assert captured.out == str(out) + '\n'

def test4(capsys):
    inputs = [10, 8]
    out = 322828856
    main(*inputs)
    captured = capsys.readouterr()    
    assert captured.out == str(out) + '\n'

def test5(capsys):
    inputs = [1, 2]
    out = 2
    main(*inputs)
    captured = capsys.readouterr()    
    assert captured.out == str(out) + '\n'

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b=map(int,input().split())
c=a-1
d=b-1
e=d**c
f=e*b

print(f)

Submission status: Accepted

Solution code:
def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    [N, K] = list(map(lambda x: int(x), inputs[0].split()))
    pattern = K * ((K - 1) ** (N - 1))
    return pattern


if __name__ == "__main__":
    ret = solve(inputs(1))
    print(ret)

Submission status: Accepted

Solution code:
def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    [N, K] = list(map(lambda x: int(x), inputs[0].split()))
    pattern = K
    for i in range(1, N):
        pattern *= K - 1
    return pattern


if __name__ == "__main__":
    ret = solve(inputs(1))
    print(ret)

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())
tmp = K
for i in range(N-1):
    tmp *= (K-1)
print(tmp)

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

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

Submission status: Accepted

Solution code:
# B問題
N, K = map(int, 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 = 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())
ans = K

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

sum = 0
for i in range(n) :
    if i == 0 :
        sum += k
    else :
        sum *= (k-1)

print(sum)

Submission status: Accepted

Solution code:
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    n, k = f()

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


solve()

Submission status: Accepted

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

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

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

print(num)

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 ,M  =list(map(int,input().split(" ")))


print(M * ((M-1)**(N-1)))

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

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
print(k * (k - 1) ** max(0, 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 = 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())

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

Submission status: Accepted

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

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

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

print(ans)

Submission status: Accepted

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

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

if n == 1:
    ans = k
else:
    ans = k * pow(k-1, n-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 = 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 -*-
"""
B - AtCoDeerくんとボール色塗り / Painting Balls with AtCoDeer
https://abc046.contest.atcoder.jp/tasks/abc046_b

"""
import sys


def solve(N, K):
    ans = K
    for _ in range(1, N):
        ans *= (K-1)
    return ans


def main(args):
    N, K = map(int, input().split())
    ans = solve(N, K)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

Submission status: Accepted

Solution code:
N,K = [int(x) for x in 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 = [int(i) for i 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)
else:
    print(k*(k-1)**(n-1))

Submission status: Accepted

Solution code:
n, k =[int(n) for n in 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:
tmp = input()
N = int(tmp.split(" ")[0])
K = int(tmp.split(" ")[1])

p = 0

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# ABC046B - AtCoDeerくんとボール色塗り / Painting Balls with AtCoDeer
n, k = list(map(int, input().rstrip().split()))
print(k * (k - 1) ** (n - 1))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
from collections import Counter

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


if __name__ == '__main__':
	main()

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(p)

Submission status: Accepted

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

Submission status: Accepted

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


def submit():
    n, k = read_input()

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


if __name__ == '__main__':
    submit()

Submission status: Accepted

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

def solve(N, K):
    print(K*(K-1)**(N-1))
                
if __name__ == '__main__':
    N, K = map(int, input().split())

    solve(N, K)

Submission status: Accepted

Solution code:
from sys import stdin
input=stdin.readline().rstrip().split()
#print(input)
for i in range(len(input)):
  input[i]=int(input[i])
  
output=1
output=input[1]*(input[1]-1)**(input[0]-1)

print(output)

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:
n,k=(int (x)for x in 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())

# 出力
print(K*pow(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:
import sys

def main():
    input = sys.stdin.readline
    N, K = map(int, input().split())

    return K * (K-1)**(N-1)


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

Submission status: Accepted

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