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

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

Submission status: Accepted

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

# 1つめは全色選択可、それ以降は前の色以外の全色選択可
ans = K * ((K - 1)**(N - 1))
print(str(ans))

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
2, 1
10
8, 7, 7, 7, 7,

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

if N>1:
  res = K*(K-1)**(N-1)
else:
  res = K

print(res)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
NK=list(map(int,input().split()))
N=NK[0]
K=NK[1]
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 = (int(x) for x in 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 * pow(k-1, n-1)
print("{}".format(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:
from sys import stdin

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

point = 1

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

print(point*k)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

first = color * 1
second = 1
if ball != 1: second = (color - 1) ** (ball-1)

print(first * second)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
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:
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N,K=MI()
    print(K*((K-1)**(N-1)))
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import math
from string import ascii_lowercase

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

Submission status: Accepted

Solution code:
import sys

data = sys.stdin.readline().rstrip()
N, K = data.split(" ")
N = int(N)
K = int(K)

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())
ans = k * pow(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())

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

Submission status: Accepted

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

ans = k

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

print(result)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools

N, K = [int(i) for i in input().split()]
a = [0] * K
c = [0] * (K - 1)
b = len(list(itertools.combinations(a,1)))

e = len(list(itertools.combinations(a,1)))

for i in range(N - 1):
    e *= len(list(itertools.combinations(c,1)))
    
print(e)

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

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

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

print(ans)

Submission status: Accepted

Solution code:
def examB():
    N, K = LI()
    ans = K*((K-1)**(N-1))
    print(ans)

import sys
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examB()

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
# ABC 046: B – AtCoDeerくんとボール色塗り / Painting Balls with AtCoDeer
n, k = [int(s) for s in input().split()]

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#Painting Balls with AtCoDeer
N, K = map(int, input().split())
S = K * (K-1) ** (N-1)
print(S)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10000)


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

    TABLE = [[-1 for x in range(K + 3)] for y in range(N + 3)]

    def recur(i, k):
        if not i < N:
            return 1

        if not TABLE[i][k] == -1:
            return TABLE[i][k]

        ans = 0
        for a in range(K):
            if not a == k:
                ans += recur(i + 1, a)

        TABLE[i][k] = ans
        return TABLE[i][k]

    return recur(0, -1)


if __name__ == '__main__':
    res = solve()
    print(res)

Submission status: Accepted

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

    TABLE = [[-1 for x in range(K + 3)] for y in range(N + 3)]

    def recur(i, k):
        if not i < N:
            return 1

        if not TABLE[i][k] == -1:
            return TABLE[i][k]

        ans = 0
        for a in range(K):
            if not a == k:
                ans += recur(i + 1, a)

        TABLE[i][k] = ans
        return TABLE[i][k]

    return recur(0, -1)


if __name__ == '__main__':
    res = solve()
    print(res)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import itertools
N,K=[int(i) for i in input().split()]
seq=[i for i in range(K)]
lst=[]
'''for i in itertools.product(seq, repeat=N):
    lst.append(i)

ans=[]
for tup in lst:
    f=0
    for ind,color in enumerate(tup):
        if(ind==len(tup)-1):
            break
        if(tup[ind+1]==color):
            f=1
            break
    if(f==0):
        ans.append(tup)
print(len(ans))'''

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

Submission status: Accepted

Solution code:
A = list(map(int, input().split()))
a = A[0]
b = A[1]
s = 0
for n in range(1, a+1):
  if n == 1:
    s = s + (n * b)
  else:
    s = s * (b-1)
print(s)

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

Submission status: Accepted

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

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

print(s)

Submission status: Accepted

Solution code:
n, k = map(int, input().rstrip("\n").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 = 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())

if K == 1 and N != 1:
    x = 0
else:
    x = K * (K-1)**(N-1)

print(x)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

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

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

ans = k

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# ABC046 B - AtCoDeerくんとボール色塗り / Painting Balls with AtCoDeer
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

N,K = nm()

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


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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from sys import exit, stdin
N, K = [int(_) for _ in stdin.readline().rstrip().split()]
print(K*(K-1)**(N-1))

Submission status: Accepted

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

main()

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
tot=n//2+n%2 
h=n//2 
ans=pow(k,1) *pow(k-1,n-1) 
print(ans)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


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().strip().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:
N,K = map(int,input().split())
ans = 0
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())
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())

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:
if __name__ == "__main__":
    inputs = list(input().split())
    n = int(inputs[0])
    k = int(inputs[1])

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
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())
colors = K
for i in range(N-1):
  colors = colors * (K-1)
print(int(colors))

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

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())
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 i in range(n-1):
    out *= k-1

print(out)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
print(K*1 * (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:
def slove():
    import sys
    input = sys.stdin.readline
    n, k = list(map(int, input().rstrip('\n').split()))
    t = 1
    for i in range(n):
        if i == 0:
            t *= k
        else:
            t *= (k - 1)
    print(t)


if __name__ == '__main__':
    slove()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter,defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+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())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

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(' '))
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:
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) ** max(0, (N - 1)))

Submission status: Accepted

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

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

Submission status: Accepted

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

answer=K
if N>1:
  for _ in range(N-1):
    answer*=(K-1)

print(answer)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#atcordeerくんとボール色ぬり
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(" "))
for i in range(n):
  if i == 0:
    result = k
  else:
    result = result * (k - 1)
print(result)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(b)

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
for _ in range(n-1):
    res *= (k-1)
print(res)

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n,k=map(int,input().split())
    print(k*((k-1)**(n-1)))
resolve()

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

Submission status: Accepted

Solution code:
def main():
  n, k = [int(x) for x in raw_input().split()]
  result = k
  for x in xrange(1, n):
      result *= (k-1)
  print(result)

main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
 
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()
 
n, k = na()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        N, K = map(int, input().split())

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


# Run main
if __name__ == '__main__':
    AtCoder().main()

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

Submission status: Accepted

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

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


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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
nk = list(map(int, input().split()))
n = nk[0]
k = nk[1]
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:
# coding: utf-8
# Your code here!

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

# print(N)
# print(K)

result = K

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

print(result)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#インポート
import sys

#入力用
def ILI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def ISI(): return map(int, sys.stdin.readline().rstrip().split())
def II(): return int(sys.stdin.readline().rstrip())
def ISS(): return sys.stdin.readline().rstrip().split()
def IS(): return sys.stdin.readline().rstrip()

N, K = ISI()
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:
SA = input().split()
SB = [int(z) for z in SA]
a = SB[0]
b = SB[1]


# a = 10
# b = 8
c = b * ((b-1) ** (a-1))
print(c)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
from collections import Counter

stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

mod = 10 ** 9 + 7

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

Submission status: Accepted

Solution code:
ball_count, color_count = (int(x) for x in input().split())
print(color_count*(color_count-1)**(ball_count-1))

Submission status: Accepted

Solution code:
n, k = [int(num) for num 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(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:
#ABC 046 B AtCoDeerくんとボール色塗り

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

ans = k

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

Submission status: Accepted

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

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

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

R = 0

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

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:
# -*- coding: utf-8 -*-

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

# solve & output
print(K * ((K-1) ** (N-1)))

Submission status: Accepted

Solution code:
def main():

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

if __name__ == '__main__':
    print(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)) if N > 2 else K)

Submission status: Accepted

Solution code:
import sys
from sys import stdin

N, K = [int(x) for x in stdin.readline().rstrip().split()]

if K < 2:
    raise Exception('Error!')

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

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

"""
def myfunc(n, k):
    if n <= 0:
        return k
    n = int(n-1)
    k = k*(k-1)
    return myfunc( n,k )

if __name__ == '__main__':
    print(int(myfunc(N, K)))
"""

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

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

print(result)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# ABC 46 B

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

    print(ans)


if __name__ == "__main__":
    resolve()

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

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

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