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

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

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*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:
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:

def myAnswer(N:int, K:int) -> int:
   return (K - 1)**(N - 1) * K

def modelAnswer():
   tmp=1
def main():
   N, K = map(int,input().split())
   print(myAnswer(N, K))
if __name__ == '__main__':
   main()

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:
_input = list(map(int, input().split(" ")))
n = _input[0]
k = _input[1]

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

print(result)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from heapq import *
import sys
from collections import *

from itertools import *
from decimal import *
import copy
from bisect import *
import time

import math
import datetime
def gcd(a,b):
    if(a%b==0):return(b)
    return (gcd(b,a%b))
sys.setrecursionlimit(10**7)
input=lambda :sys.stdin.readline().rstrip()

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

Submission status: Accepted

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


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

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

Submission status: Accepted

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

def comnb(a,b):
    return b*((b-1)**(a-1))
print(comnb(N,K))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
howmany = K * (K - 1) ** (N - 1)
if K < 2**31:
    print(howmany)
else:
    pass

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:
A=list(map(int,input().split()))
ans=A[1]
for i in range(0,A[0]-1):
    ans=ans*(A[1]-1)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a, b = list(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*(pow(k-1,n-1)))

Submission status: Accepted

Solution code:
if __name__ == "__main__":
  n,k = map(int,input().split())
  ans = int(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:
# solution

nim, mike = map(int, input().split())
print(mike * (mike - 1) ** (nim - 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())
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:
from sys import stdin

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

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

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

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

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

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:
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


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

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

Submission status: Accepted

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

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

print(result)

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

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

count = y

for i in range(x-1):
    count *= y-1
print(count)

Submission status: Accepted

Solution code:
N = list(map(int,input().split()))
ans = N[1]
for i in range(N[0]-1):
    ans *= N[1]-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 = k

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

Submission status: Accepted

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

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

print(output)

Submission status: Accepted

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

print(cnt)

Submission status: Accepted

Solution code:
url = "https://atcoder.jp/contests/abc046/tasks/abc046_b"

def main():

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


if __name__ == '__main__':
    main()

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

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline


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:
#!/usr/bin/env python3

d, n = map(int,input().split())
ans = n*(n-1)**(d-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:
# ABC 046: B – AtCoDeerくんとボール色塗り / Painting Balls with AtCoDeer
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 - 1)**(N - 1) * K
print(ans)

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
#n個をk色で塗る

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

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 = int(input())
#n = 322828856
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())
ans = k
for _ in range(n-1):
  ans *= k-1
  
print(ans)

Submission status: Accepted

Solution code:
import sys
import math
MAX_INT = int(10e11)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N,K = IL()
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:
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

n, k = na()

if n == 1:
    print(k)
    exit(0)

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

print(ans)

Submission status: Accepted

Solution code:
if __name__ == "__main__":
  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 = 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 * ((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:
import math
n,k=map(int,input().split()) #nボールk種類色
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())

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


if __name__ == '__main__':
    main()

# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())

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

Submission status: Accepted

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

if n==1:
    print(k)

else:
    print(k*pow(k-1,n-1))

Submission status: Accepted

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

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

print(result)

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:
from itertools import permutations
import sys

sys.setrecursionlimit(10 ** 6)
from bisect import *
from collections import *
from heapq import *

def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def SI(): return sys.stdin.readline()[:-1]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
int1 = lambda x: int(x) - 1
def MI1(): return map(int1, sys.stdin.readline().split())
def LI1(): return list(map(int1, sys.stdin.readline().split()))
p2D = lambda x: print(*x, sep="\n")
dij = [(1, 0), (0, 1), (-1, 0), (0, -1)]

def main():
    n,k=MI()
    ans=k*pow(k-1,n-1)
    print(ans)

main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")


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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
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 = list(map(int, input().split()))

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

print(ans)

Submission status: Accepted

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

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

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


if __name__ == '__main__':
    main()

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

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

Submission status: Accepted

Solution code:
#import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""

# Written by NoKnowledgeGG @YlePhan

import math
#mod = 10**9+7

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

Submission status: Accepted

Solution code:
import itertools
import math
import sys
import heapq
from collections import Counter
from collections import deque
from fractions import gcd
INF = 1 << 60
sys.setrecursionlimit(10 ** 6)

#ここから書き始める
n, k = map(int, input().split())
ans = k
if n >= 2:
    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())
if n == 1:
    ans = k
    print(ans)
else:
    ans = k*(k-1)**(n-1)
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
balls, colors = map(int,input().split())

ans = 1

for i in range(1,balls+1):
  if i == 1:
    ans *= colors
  else:
    ans *= colors - 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:
import sys

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

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

print("{}".format(pattern))

Submission status: Accepted

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

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:
import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

if __name__ == '__main__':
    b, c = map(int, input().split())

    print(c * ((c-1) **(b-1)))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions
from decimal import Decimal
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

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

Submission status: Accepted

Solution code:
import sys

def solve():
    input = sys.stdin.readline
    N, K = map(int, input().split())
    total = K
    for i in range(N-1): total *= (K - 1)
    print(total)
    return 0

if __name__ == "__main__":
    solve()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def resolve():

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


resolve()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
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=K*((K-1)**(N-1))
print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

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

Submission status: Accepted

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]

n, k = MAP()
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())
ans = 1
if n == 1:
	print(k)
else:
	ans = k*((k-1)**(n-1))
	print(ans)

Submission status: Accepted

Solution code:
N,K=list(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())

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import defaultdict, deque
import sys
import heapq
import bisect
import itertools
import queue
import copy
import time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7

def inp(): return int(sys.stdin.readline())

def inpl(): return list(map(int, sys.stdin.readline().split()))

def inpl_str(): return list(sys.stdin.readline().split())

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

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:
import sys
input = sys.stdin.readline

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

Submission status: Accepted

Solution code:
import math

N, K = list(map(int, input().split()))
print(int(K * math.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:
#ABC046.B
N,K = map(int,input().split())
if N >=2:
    c = K*(K-1)**(N-1)
elif N ==1 :
    c = K
print(c)

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
        continue
    ans *= (k - 1)
print(ans)

Submission status: Accepted

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

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

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

x=k

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

print(x)

Submission status: Accepted

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

Submission status: Accepted

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

n = n-1

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N,K=MI()
    print(K*pow(K-1,N-1))

main()

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# from math import factorial,sqrt
# from itertools import permutations as permus
# from fractions import gcd
# from collections import deque,Counter

# import numpy as np
# import scipy as scp

# 入力の受け取り
n,k = map(int,input().split())

ans = k * (k-1)**(n-1)
print(ans)
# print("{:.10f}".format(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())

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

Submission status: Accepted

Solution code:
# import bisect
# import copy
# import fractions
# import math
# import numpy as np
# from collections import Counter, deque
# from itertools import accumulate,permutations, combinations,combinations_with_replacement,product

def resolve():
    N,K=map(int,input().split())
    val=K
    for i in range(2,N+1):
        val*=(K-1)
    print(val)

resolve()

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

Submission status: Accepted

Solution code:
a,b=map(int, raw_input().split())
ans=b
for i in range(a-1):
    ans=ans*(b-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:
a,b=map(int,input().split());print(b*(b-1)**~-a)

Submission status: Accepted

Solution code:
if __name__ == "__main__":
    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 = list(map(int, input().split()))

if n == 0:
  print(0)
  exit()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
## coding: UTF-8
s = input().split()
t = [int(p) for p in s]
#print(t)

N = t[0]
K = t[1]

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

Submission status: Accepted

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

Submission status: Accepted

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

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