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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,k=list(map(int,input().split()))
if(n==k):
    print(k)
    
elif(n>k):
    if(n%2==0):
        print(int(n/k))
        
    elif(n%2 != 0):
        print(int((n/k)+0.5))
        
elif(n<k):
    if(n%2==0):
        print(int(n/2))
    elif(n==1):
        print(k)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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_balls - 1)
  print(product)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
ans = 1
switcher = True
for n in range(N):
  ans *= K
  if switcher:
    K -= 1
  else:
    K += 1
  switcher = not switcher
  
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans=1

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

Submission status: Wrong Answer

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

ans=1

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

Submission status: Wrong Answer

Solution code:
a = input().strip().split(" ")
n = int(a[0])
k = int(a[1])
if n == 1:
    print(n*k)
elif n >= k:
    print(n)
else:
    print(k//n)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8

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

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

print(k)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def ABC046_B():
    import numpy as np
    n,k = map(int,input().split())
    print(n,k)

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

    print(ans)
    

ABC046_B()

Submission status: Wrong Answer

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

i=1
ans=n
while i<n:

    ans=ans*(n-1)
    i+=1

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
def resolve():
    n, k = map(int, input().split())
    if n > 1:
        print(n * pow(n - 1, k - 1))
    else:
        print(k)
resolve()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
# For taking integer inputs.
import math
from decimal import Decimal
from itertools import permutations


def inp():
    return(int(input()))


# For taking List inputs.
def inlist():
    return(list(map(int, input().split())))


# For taking string inputs. Actually it returns a List of Characters, instead of a string, which is easier to use in Python, because in Python, Strings are Immutable.
def instr():
    s = input()
    return(list(s[:len(s)]))


# For taking space seperated integer variable inputs.
def invr():
    return(map(int, input().split()))


n, k = invr()

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

print(c)

Submission status: Wrong Answer

Solution code:
# For taking integer inputs.
import math
from decimal import Decimal
from itertools import permutations


def inp():
    return(int(input()))


# For taking List inputs.
def inlist():
    return(list(map(int, input().split())))


# For taking string inputs. Actually it returns a List of Characters, instead of a string, which is easier to use in Python, because in Python, Strings are Immutable.
def instr():
    s = input()
    return(list(s[:len(s)]))


# For taking space seperated integer variable inputs.
def invr():
    return(map(int, input().split()))


n, k = invr()

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

print(c)

Submission status: Wrong Answer

Solution code:
# For taking integer inputs.
import math
from decimal import Decimal
from itertools import permutations


def inp():
    return(int(input()))


# For taking List inputs.
def inlist():
    return(list(map(int, input().split())))


# For taking string inputs. Actually it returns a List of Characters, instead of a string, which is easier to use in Python, because in Python, Strings are Immutable.
def instr():
    s = input()
    return(list(s[:len(s)]))


# For taking space seperated integer variable inputs.
def invr():
    return(map(int, input().split()))


n, k = invr()

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

print(c)

Submission status: Wrong Answer

Solution code:
# For taking integer inputs.
import math
from decimal import Decimal
from itertools import permutations


def inp():
    return(int(input()))


# For taking List inputs.
def inlist():
    return(list(map(int, input().split())))


# For taking string inputs. Actually it returns a List of Characters, instead of a string, which is easier to use in Python, because in Python, Strings are Immutable.
def instr():
    s = input()
    return(list(s[:len(s)]))


# For taking space seperated integer variable inputs.
def invr():
    return(map(int, input().split()))


n , k = invr()

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a=input().split(" ")
part=0
 
for i in range(int(a[0])):
	if i==0:
		part=a[1]
	else:
		part=part*(int(a[1])-1)
 
print(part)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,m=1,10
for i in range(n-1):
    m*=(m-1)
print(m)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

possibilities = 1

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

Submission status: Wrong Answer

Solution code:
def fact(n,k):
    ans=1
    for i in range(0,n):
        if(i%2==0):
            ans*=k
        if(i%2==1):
            ans*=(k-1)
    return ans;
n,k=map(int,input().split())
ans=fact(n,k)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def fact(n):
    ans=1
    if(n==0 or n==1):
        return 1
    for i in range(1,n+1):
        ans*=i
    return ans;
n,k=map(int,input().split())
ans=fact(k)//fact(k-n)
print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if a == 1:
	print(b)
elif a == 2:
	print(b * (b-1))
elif a % 2 == 1:
	print((b * (b-1)) ** (a // 2) * b)
else:
	print((b * (b-1)) ** (a // 2))

Submission status: Wrong Answer

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

if a == 1:
	print(b)
elif a == 2:
	print(b * (b-1))
elif a % 2 == 1:
	print((b * (b-1)) * (a // 2) * b)
else:
	print((b * (b-1)) *( a // 2))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

######################

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
try:
    n = int(input())
    k = int(input())
    print(k * (k - 1) ** (n - 1))
except:
    pass

Submission status: Wrong Answer

Solution code:
def fact(x):
    f=1
    for i in range(1,x+1):
        f=f*i

    return f

N,K=input().split()

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

y=fact(K)/fact(K-N)

print(int(y))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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


if n == 1:
  print(k)

else:
  for i in range(1,k+1):
    if i != 1:
      count = count * i
    else:
      pass
  
  print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, k = (int(i) for i in input().split())  
first = n*k#1個目はn*k
if n==1:
    print(first)
else:
    secound =(k-1)**(n-1) #k-1をkの回数だけしたい
    goukei=first*secound
    print(goukei)

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

print(first * second)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if n == 1:
    print(k)
elif k % 2 == 0:
    print((n * (n - 1)) ** (k // 2))
elif k % 2 != 0:
    print((n * (n - 1)) ** ((k - 1) // 2) * n)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if N <= K:
    print(int(math.factorial(K)/math.factorial(K-N)))
    
else:
    print(((K-1)**(N-1))*K)

Submission status: Wrong Answer

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

if N <= K:
    print(int(math.factorial(K)/math.factorial(K-N)))
    
else:
    print((K-1)**(N-1)*K)

Submission status: Wrong Answer

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

if n == 1:
    print(k)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from math import factorial
n,k = map(int,input().split(' '))
ans = 0

if n==k:
  ans = factorial(k)
elif n>k:
  ans = factorial(k) * pow(k-1,n-k)
else:
  ans = factorial(k)//factorial(k-n)

print(ans)

Submission status: Wrong Answer

Solution code:
from math import factorial
n,k = map(int,input().split(' '))
ans = 0

if n==k:
  ans = factorial(k)
elif n>k:
  ans = factorial(k) * (n-k) * (k-1)
else:
  ans = factorial(k)//factorial(k-n)

print(ans)

Submission status: Wrong Answer

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

for i in range(1,n):
    if i%2 == 0:
        ans = ans*k
    elif i%2 != 0:
        ans = ans*(k-1)

print(ans)

Submission status: Wrong Answer

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

if n == 1:
    ans=k
elif n%2 != 0:
    ans = ans*(k**(n//2))*((k-1)**(n//2)) 
else:
    ans = ans*(k**((n//2)-1))*((k-1)**(n//2))

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

child = 1

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
n,k = list(map(int, input().split()))
combination = k

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

a = k*((N-1)**(k-1))

print(a)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

    print(res)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

    print(res)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
iN,iK = [int(_) for _ in input().split()]
print(iK*(iK**(iN-1)))

Submission status: Wrong Answer

Solution code:
iN,iK = [int(_) for _ in input().split()]
print(iN*(iK**(iN-1)))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s=input().split()
N=int(s[0])
K=int(s[1])
print(K*((K-1)**N))

Submission status: Wrong Answer

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

if a[0] < a[1]:
  print(a[0] * (a[1]-1) +1)
elif a[0] == a[1]:
  print(a[0])
elif a[0] > a[1]:
  print(a[0]*((a[1]-1)**(a[0]-1)))

Submission status: Wrong Answer

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

print(a[0] * (a[1]-1) +1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import scipy.misc as s
i = raw_input().split()
print s.comb(int(i[0]), int(i[1]), 1)

Submission status: Wrong Answer

Solution code:
def main():
	inpt = raw_input().split()
	n = int(inpt[0])
	k = int(inpt[1])
	ans = k
	for i in range(2, n):
		ans *= k - 1
	print ans
	
main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def ans():
	l = list(map(int, raw_input().split()))
	ans = l[1]
	for i in range(l[0] - 1):
		ans *= l[1] - 1
	return ans

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

Submission status: Wrong Answer

Solution code:
l=map(int, raw_input().split())
ans=l[1]*((l[1]-1)**(l[0]-1))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#a = int(input());
#b = int(input());
a, b = map(int, input().split())
res = 1
if a <= b:
  for i in range(1, a + 1, 1):
    res *= b;
    b = b - 1;
else:
  res = b
  b = b - 1;
  a = a - 1;
  for i in range(a):
    res *= b;

print(res)

Submission status: Wrong Answer

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


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


def main(n, k):
    try:
        l = list(itertools.permutations([_ for _ in range(n)], k))
        return len(l)
    except IndexError:
        return len(list(itertools.product([_ for _ in range(n)],
                                          [_ for _ in range(k)])))

print(main(n, k))
# print(main(10, 8))

Submission status: Wrong Answer

Solution code:



if __name__=='__main__':
    n,k = map(int,input().split())
    if n==1:
        print(k)
    elif n==2:
        print((k-1)*(k))
    else:
        print(((n-1)*(k-1))+k)

Submission status: Wrong Answer

Solution code:
import itertools

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

k_ = list(range(0,k))

c = 0
for e in itertools.permutations(k_,n):
    c+=1

print(c)

Submission status: Time Limit Exceeded

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

Submission status: Accepted

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

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

Submission status: Accepted

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

n = int(nk[0])
k = int(nk[1])

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

print(p)

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def answer(n: int, k: int) -> int:
    return k * (k - 1) ** (n - 1)


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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 6)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")
al = "abcdefghijklmnopqrstuvwxyz"
AL = al.upper()

n,k = I()

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

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

print(int(s))

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

Submission status: Accepted

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

if __name__ == "__main__":
    solve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, k = 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 * ((K-1) ** (N-1)) 

print(ans)

Submission status: Accepted

Solution code:

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

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

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

Submission status: Accepted

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

N = int(lst[0])
K = int(lst[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())
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())

def calculate(n, k):
    print(k * pow(k-1,n-1))

calculate(N, K)