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

print(ans)

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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


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

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

    return 0

if __name__ == "__main__":
    solve()

Submission status: Accepted

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

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

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

Submission status: Accepted

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

print(getCombinationCount(N, K))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#046_B
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())
print(int(K*(K-1)**(N-1)))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

if __name__ == '__main__':
    resolve()

Submission status: Accepted

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

if __name__ == '__main__':
    resolve()

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/abc046/tasks/abc046_b

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

c = [k - 1] * 1000
c[0] = k
c = c[0:n]

result = 1
for i in c:
    result *= i

print(result)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
# import math
# import decimal
# import queue
# import bisect
# import heapq
# import time
# import itertools
# from fractions import Fraction

mod = int(1e9+7)
INF = 1<<29

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

if __name__=='__main__':
    main()

Submission status: Accepted

Solution code:
def main():
    ball_num, color_num = map(int, input().split())
    print(color_num * pow(color_num - 1, ball_num - 1))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

# 最初の一回目はKパターン
ans = K
for i in range(1,N):
    if K-1>0:
        ans *= K-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:
#!/usr/bin/env python3
import sys


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


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

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
# your code goes 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())

c = 1
ans = K

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

print(ans*c)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#B - AtCoDeerくんとボール色塗り

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

N=int(N)
K=int(K)

y=int(K*(K-1)**(N-1))
print(y)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(N: int, K: int):
    print(K*((K-1)**(N-1)))
    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:
  print((k-1)**(n-1)*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:
# -*- coding: utf-8 -*-

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

Submission status: Accepted

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

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

Submission status: Accepted

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

ans = 1
for i in range(balls):
    if i == 0 :
        ans *= colors
    else:
         ans *= colors - 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())
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:
a , b = map(int,input().split())

ans = b * (b-1)**(a - 1)

print(ans)

Submission status: Accepted

Solution code:
#ABC046

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

Submission status: Accepted

Solution code:
import itertools
N,K=map(int,input().split())
ans=1
flag=True

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

print(ans)

Submission status: Accepted

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

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)

Submission status: Accepted

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


if n == 1:
  print(k)

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

  print(count)

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:
# B - AtCoDeerくんとボール色塗り
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*pow(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 = [int(x) for x in 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:
n,k = 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))) if n != 1 else print(k)

Submission status: Accepted

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

ans = k

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

print(str(ans))

Submission status: Accepted

Solution code:
a,b = map(int,input().split())
ans = b*pow(b-1,a-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 sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
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 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 = float('inf')
mod = 10 ** 9 + 7

n, k = MAP()
print(k * (k - 1) ** (n-1))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# 入力 : 数字2つ
N, K = map(int, input().split())

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# ボール色ぬり

#input
n, k = [int(a) for a in input().split()]

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
def sum_of_pattern_paint_balls(sum_of_balls, paint_colors):

    paint_pattern = paint_colors
    for i in range(1, sum_of_balls):
        paint_pattern = paint_pattern * (paint_colors - 1)

    return paint_pattern


if __name__ == '__main__':
    sum_of_balls, paint_colors = map(int, input().split())
    print(sum_of_pattern_paint_balls(sum_of_balls, paint_colors))

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
N,K = [int(i) for i in 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:
"""
author : halo2halo
date : 2, Feb, 2020
"""

import sys
import itertools

import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

a,b=(map(int, readline().split()))
print(b*(b-1)**(a-1))

Submission status: Accepted

Solution code:
def pin(type=int):
    return map(type,input().split())

#本番入力
N,K=pin()

#処理
print(K*((K-1)**(N-1)))

Submission status: Accepted

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

ways = 1

ways *= K

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

print(ways)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:


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

    print(res)

if __name__ == "__main__":
    main()

Submission status: Accepted

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

ans = K
for i in range(2,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())
result = 1

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

print(result)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

# N K ボールの個数と色の数
n, k = map(int, input().split())

# 最初は色の数、それ以降は色の数 - 1 での組合せ
color = k * ((k - 1) ** (n - 1))

print(color)

Submission status: Accepted

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

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

print(count)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#python3
def 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)

main()

Submission status: Accepted

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

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

Submission status: Accepted

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

total = 0

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

print(total)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


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

Submission status: Accepted

Solution code:
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n,k=INTM()
    print(((k-1)**(n-1))*k)
if __name__ == '__main__':
    do()

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

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

print(A)

Submission status: Accepted

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

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


def main():
    #TrainingCamp()
    PaintingBalls()


if __name__ == "__main__":
    main()

Submission status: Accepted

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

for n in range(N):
  if n == 0:
    ans += K
    continue

  ans *= (K - 1)

print(ans)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
N, K = [int(x) for x in input().split()]
ans = K * (K - 1) ** (N - 1)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# AtCoder Beginner Contest 045 - B
# -*- encoding: UTF-8 -*-

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

p = (k-1) ** n + (k-1) ** (n-1)

print(p)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

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

print(n)

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())  
first = n*k
if n==1:
    print(first)
else:
    secound =(k-1)**(n-1)
    goukei=k*secound
    print(goukei)

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

ans=nk[1]*((nk[1]-1)**(nk[0]-1))
print(int(ans))

Submission status: Accepted

Solution code:
# import numpy as np
# import math
import sys
input = sys.stdin.readline

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

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

print(count)

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

if n ==1:
  print(str(k))
else:
  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:
# coding: utf-8
import sys


def main(argv=sys.argv):

    ball_count, color_count = map(int, input().split(' '))

    print(color_count * (color_count - 1) ** (ball_count - 1))

    return 0


if __name__ == '__main__':
    sys.exit(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())

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

import sys
import numpy as np
from collections import deque as deq

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

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

Submission status: Accepted

Solution code:
# coding: utf-8
import sys

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

if __name__ == '__main__':
  sys.exit(main())

Submission status: Accepted

Solution code:
# coding: utf-8
import sys


def main(argv=sys.argv):
  N, K = map(int, input().split())
  print(K * ((K - 1) ** (N - 1)))
  
  return 0
 
if __name__ == '__main__':
  sys.exit(main())

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
def resolve():
        input = sys.stdin.readline
        N,K=map(int,input().rstrip().split())

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




import sys
from io import StringIO
import unittest

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """2 2"""
        output = """2"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """1 10"""
        output = """10"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """10 8"""
        output = """322828856"""
        self.assertIO(input, output)

if __name__ == "__main__":
    #unittest.main()
    resolve()

Submission status: Accepted

Solution code:

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

Submission status: Accepted

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

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

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 = list(map(int, input().split()))
n = N
print(K*((K-1)**(N-1)))
#print(8*(7**9))

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

n, k = map(int, sys.stdin.readline().split())

def main():
    ans = k * (k - 1)**(n-1)
    return ans

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

Submission status: Accepted

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