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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

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

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

Submission status: Accepted

Solution code:
import re
import copy

def accept_input():
    N,K = map(int,input().split())
    return N,K

N,K = accept_input()


if K == 1:
    print(N)
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:
def resolve():
    import sys
    input = sys.stdin.readline

    n, k = [int(x) for x in input().rstrip().split(" ")]

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


if __name__ == "__main__":
    resolve()

Submission status: Accepted

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

if N != 1 :
  for i in range(1,N):
    num *= K-1

print(num)

Submission status: Accepted

Solution code:
MOD = 10**11

def fast_pow(x, n, MOD):
    res = 1
    while n:
        if n & 1:
            res = res * x % MOD
        x = x * x % MOD
        n >>= 1
    return res


n, k = map(int,input().split())
if n == 1:
    print(k)
else:
    print(k * fast_pow(k-1, n-1, MOD))

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


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


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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
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:
import sys
sys.setrecursionlimit(4100000)
import math
import itertools
INF = float('inf')
from heapq import heapify, heappop, heappush
import collections
import bisect

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

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()

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

Submission status: Accepted

Solution code:
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    N, K = map(int, readline().split())
    ans = K

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

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

    

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, K  = [int(x) for x in input().split()]
ans = (K-1)**(N-1)*K
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(' '))

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
str_line = input().split(" ")
num = int(str_line[0])
kind = int(str_line[1])
ans = kind 

for i in range(num-1):
    ans *=(kind - 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 math
import numpy as np
import sys
import os
from operator import mul

sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(_S())
def LS(): return list(_S().split())
def LI(): return list(map(int,LS()))

if os.getenv("LOCAL"):
    inputFile = basename_without_ext = os.path.splitext(os.path.basename(__file__))[0]+'.txt'
    sys.stdin = open(inputFile, "r")
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353    

N,K = LI()

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

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

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 sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""


n,k = m()

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

a, b = list(map(int, input().split(' ')))
ans = b * pow(b-1, a-1)
print(ans)

Submission status: Accepted

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

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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#
# abc046 b
#

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)


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


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

print(ans)

Submission status: Accepted

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





if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N, K = LI()

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

Submission status: Accepted

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

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

print(number)

Submission status: Accepted

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

numk=k
for _ in range(2,n+1):
    numk=numk*(k-1)
print(numk)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# B - AtCoDeerくんとボール色塗り
def main():
    n, k = map(int,input().split())

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


if __name__ ==  "__main__":
    main()

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

Submission status: Accepted

Solution code:
sample = input() # two numbers in a string
new_sample = sample.split(" ")

ball = int(new_sample[0]) # number of balls
color = int(new_sample[1]) # number of colors
if ball > 1 and color == 1:
  print(0)
else:
  product = color
  for i in range(1, ball):
    product *= (color-1)
  print(product)

  
# 3 balls, 10 colors
# 1st spot, 10 choices
# 2nd spot, 9 choices
# 3rd spot, 9 choices

Submission status: Accepted

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

Submission status: Accepted

Solution code:
i = input()
j = i.split()
num_balls = int(j[0])
num_colors = int(j[1])
product = num_colors
if(num_balls > 1 and num_colors == 1):
  print(0)
else:
  for i in range(1, num_balls):
    product *= (num_colors - 1)
  print(product)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N, K = list(map(lambda n: int(n), 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())
print(b*((b-1)**(a-1)) if a>1 else b)

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:
  ans = k
  for _ in range(2, 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(int, input().split())

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

Submission status: Accepted

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

var = k

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

print(var)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# ABC_046_B_AtCoDeerくんとボール色塗り.py

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from sys  import stdin,stdout

import bisect

import math

def st():
    return list(stdin.readline().strip())

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

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

def mp():
    return map(int,stdin.readline().split())

def pr(n):
    stdout.write(str(n)+"\n")

def soe(limit):
    l=[1]*(limit+1)
    prime=[]
    for i in range(2,limit+1):
        if l[i]:
            for j in range(i*i,limit+1,i):
                l[j]=0

    for i in range(2,limit+1):
        if l[i]:
            prime.append(i)
    return prime

def segsoe(low,high):
    limit=int(high**0.5)+1
    prime=soe(limit)
    n=high-low+1
    l=[0]*(n+1)
    for i in range(len(prime)):
        lowlimit=(low//prime[i])*prime[i]
        if lowlimit<low:
            lowlimit+=prime[i]
        if lowlimit==prime[i]:
            lowlimit+=prime[i]
        for j in range(lowlimit,high+1,prime[i]):
            l[j-low]=1
    for i in range(low,high+1):
        if not l[i-low]:
            if i!=1:
                print(i)
                
def gcd(a,b):
    while b:
        a,b=b,a%b
    return a

def power(a,n):
    r=1
    while n:
        if n&1:
            r=(r*a)
        a*=a
        n=n>>1
    return r

    
def solve():
    n,k=mp()
    pr(k*(k-1)**(n-1))
for _ in range(1):
    solve()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

ans=K

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

Submission status: Accepted

Solution code:
from math import pow

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

Submission status: Accepted

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

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

Submission status: Accepted

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

print(a)

Submission status: Accepted

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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

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)


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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    n, k = map(int, input().split())
    if n == 1:
        print(k)
        sys.exit()
    r = k
    r *= pow(k - 1, n - 1)
    print(r)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

resolve()

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


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

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

    return


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
n, k = map(int, input().split())

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

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

Submission status: Accepted

Solution code:
import sys
N,K = map(int,sys.stdin.readline().rstrip().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*(K-1)**(N-1))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
LL = input().split()
N = int(LL[0])
K = int(LL[1])
if N ==1 or K ==1:
  ans = N*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:
n,k = map(int,input().split())
ans = k * (k-1)**(n-1)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
s = input().split()

# ボールの数n
n = int(s[0])

# 色の種類k
k = int(s[1])

answer = 1

for num in range(n - 1):
    answer *= k - 1

answer *= k

print(int(answer))

Submission status: Accepted

Solution code:
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


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

    N, K = il()

    ret = 1
    for n in range(N):
        ret *= K
        if n == 0:
            K -= 1

    print(ret)



if __name__ == '__main__':
    main()

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

input = sys.stdin.readline

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

dp=[[0 for _ in range(n+1)] for _ in range(k+1)]

for i in range(n+1):
  for j in range(k+1):
    if i>1 and j>0:
      dp[j][i]=(j-1)*dp[j][i-1]
    elif i==1 and j>0:
      dp[j][i]=j
    else:
      dp[j][i]=0

print(dp[k][n])

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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:
import sys
sys.setrecursionlimit(500000)
MOD = 10**9+7

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

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

def main():
    N, K = mi()
    ans = K
    for i in range(N-1):
        ans *= K-1
    print(ans)


if __name__ == '__main__':
    main()