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

def main(n,k):
    ans=k
    for i in range(1,n):
        ans=ans*(k-1)
        if ans >2**31-1:
            return 2**31-1
    return ans

if __name__=='__main__':
    n,k=readinput()
    ans=main(n,k)
    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())

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

Submission status: Accepted

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


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

    print(ans)
    

ABC046_B()

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

Submission status: Accepted

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


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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

a=[int(s[0]),int(s[1])]

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

Submission status: Accepted

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

Submission status: Accepted

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

i=1
ans=k
while i<n:

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

print(M*(M-1)**(N-1))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
from collections import defaultdict

def readInt():
  return int(input())
def readInts():
  return list(map(int, input().split()))
def readChar():
  return input()
def readChars():
  return input().split()

n,k = readInts()
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())

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

print(pat)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(rs())
def rs_(): return [_ for _ in rs().split()]
def ri_(): return [int(_) for _ in rs().split()]

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import 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())
    print(k * pow(k - 1, n - 1))
resolve()

Submission status: Accepted

Solution code:


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    N, K = read_ints()
    return K*(K-1)**(N-1)


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

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

Submission status: Accepted

Solution code:
import sys
import numpy as np
import random
from decimal import Decimal
import itertools
import re
import bisect
from collections import deque, Counter
from functools import lru_cache

sys.setrecursionlimit(10**9)
INF = 10**13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
def SERIES(n): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ')
def GRID(h,w): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ').reshape(h,-1)[:,:w]
def GRIDfromString(h,w): return np.frombuffer(sys.stdin.buffer.read(), 'S1').reshape(h,-1)[:,:w]
MOD = 1000000007

def main():
	n, k = LI()
	print(k*(k-1)**(n-1))

if __name__ == '__main__':
    main()

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#! env python
# -*- coding: utf-8 -*-

import os
import sys


# ac_py.main
# Date: 2020/06/14
# Filename: main 
# Author: acto_mini

def main():
    N, K = map(int, input().split())
    # all = K ** N
    # out_single, out_multi = 0, 0
    # for i in range(2, N + 1):
    #     out_multi += (N - i + 1) * K
    print(K * ((K - 1) ** (N - 1)))
    return


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
nums = [int(e) for e in input().split()]
val = nums[1]
for i in range(nums[0]-1):
    val = val*(nums[1]-1)
print(val)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def countpattern(N, K) :
  pattern = K
  for i in range(1, N) : 
    pattern *= K - 1
    
  return pattern

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

print(countpattern(N, K))

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import math
def I():return int(sys.stdin.readline().replace("\n",""))
def I2():return map(int,sys.stdin.readline().replace("\n","").split())
def S():return str(sys.stdin.readline().replace("\n",""))
def L():return list(sys.stdin.readline().replace("\n",""))
def Intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def Lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\n","").split()))

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

Submission status: Accepted

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

if K == 2:
    print(2)
else:
    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:
import sys

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

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

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

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

Submission status: Accepted

Solution code:

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


def func(balls, colors):
    combination = colors * (colors - 1) ** (balls - 1)
    print(combination)


func(balls=n, colors=k)

Submission status: Accepted

Solution code:
import sys
import math
def v():
    n,k=tuple(map(int,sys.stdin.readline().split()))
    res=k*(k-1)**(n-1)
    print(res)
if __name__=='__main__':v()

Submission status: Accepted

Solution code:
import math

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

print(int(math.pow(k-1, n-1) * k))

Submission status: Accepted

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

Submission status: Accepted

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

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

print(sum)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

print(b * (b - 1) ** (a - 1))

Submission status: Accepted

Solution code:
"""解説から
1. Bi(1<=i<=N)のボールの中の左端B1のボールに塗る色を決める(K通り)
2. 2<=i<=Nのボールの塗る色を順に決めていく
    この時、B(i-1)のボールと異なる色であれば何色で塗ってもよい(K-1通り)
3. 1と2の前提からK*(K-1)**(N-1)通りの塗り方ができる
"""
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) if N>=2 else K)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
from math import factorial
sys.setrecursionlimit(10**6)
input = lambda: sys.stdin.readline().rstrip()
inf = float("inf") # 無限

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

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

cases = K

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

print(cases)

Submission status: Accepted

Solution code:
import sys

number = sys.stdin.readline().split(' ')

N = int(number[0])
K = int(number[1])

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

print(ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

print(sum)

Submission status: Accepted

Solution code:
import collections
 
#文字列を一文字ずつ取得したいとき
def inputStrOnebyOne():
    s = list(input())
    return s
 
#整数を一つずつリストに入れる
def inputOnebyOne_Int():
    a = list(int(x) for x in input().split())
    return a
 
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())
answer=K

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

print(answer)

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

Submission status: Accepted

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

Submission status: Accepted

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

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

# In[8]:


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


# In[9]:


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


# In[ ]:

Submission status: Accepted

Solution code:
def resolve():
    # 整数 1 つ
    # n = int(input())
    # 整数複数個
    n, k = map(int, input().split())
    # 整数 N 個 (改行区切り)
    # N = [int(input()) for i in range(N)]
    # 整数 N 個 (スペース区切り)
    # N = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    # A = [list(map(int, input().split())) for i in range(H)]

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


resolve()

Submission status: Accepted

Solution code:
def combination(n, r):
    res_n = 1
    res_r = 1

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

    for _ in range(r):
        res_r *= r
        r += 1

    return res_n // res_r

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

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

print(res)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache


#############
# Constants #
#############

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

#############
# Functions #
#############

######INPUT######
def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()

#####Shorten#####
def DD(arg): return defaultdict(arg)


#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i])*n**i for i in range(len(str(X))))

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
#############

N,K = IL()

P(K*(K-1)**(N-1))

Submission status: Accepted

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

ret = K
for i in range(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:
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
from sys import stdin
def LI(): return list(map(int,stdin.readline().rstrip().split()))
li = LI()

n,k = [li.pop(0) for i in range(2)]

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

print(ans)

Submission status: Accepted

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

if a[0] == 1:
  answer = a[1];
else:
  answer = a[1]*(a[1]-1)**(a[0]-1)

print(answer)

Submission status: Accepted

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


p = k  ## 1個目のボールはK通り
for i in range(n-1):
    ## 2個目以降は、k-1 通り
    p = p*(k-1)

print(p)

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

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

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

import sys
# import time
# import math
# import numpy as np
# import scipy.sparse.csgraph as cs            # csgraph_from_dense(ndarray, null_value=inf), bellman_ford(G, return_predecessors=True), dijkstra, floyd_warshall
# import random                                # random, uniform, randint, randrange, shuffle, sample
# import string                                # ascii_lowercase, ascii_uppercase, ascii_letters, digits, hexdigits
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from operator import itemgetter              # itemgetter(1), itemgetter('key')
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product, permutations  # product(iter, repeat=n), permutations(iter[,r])
# from itertools import combinations, combinations_with_replacement
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed)
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import copy, deepcopy              # use deepcopy to copy multi-dimentional matrix without reference
# from fractions import gcd                    # for Python 3.4 (previous contest @AtCoder)



def main():
    mod = 1000000007                # 10^9+7
    inf = float('inf')              # sys.float_info.max = 1.79...e+308
    # inf = 2 ** 64 - 1             # (for fast JIT compile in PyPy) 1.84...e+19
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    
    n, k = mi()
    print(k * pow(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 * ((K - 1) ** (N-1)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
import copy

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

Submission status: Accepted

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

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