1. Problem
2. My Solution
import sys
def permutation(level):
if level >= m:
res.append(arr.copy())
else:
for i in range(1, n+1):
if visited[i] == True:
continue
else:
arr[level] = i
visited[i] = True
permutation(level+1)
visited[i] = False
n, m = map(int,sys.stdin.readline().rstrip().split())
visited = [False] * (n+1)
arr = [0] * m
res = []
permutation(0)
for i in res:
if i == sorted(i):
print(' '.join(map(str,i)))
3. Others' Solutions
4. Learned
1. Problem
2. My Solution
import sys
def permutation(level):
if level >= m:
res.append(arr.copy())
else:
for i in range(1, n+1):
arr[level] = i
permutation(level+1)
n, m = map(int,sys.stdin.readline().rstrip().split())
arr = [0] * m
res = []
permutation(0)
for i in res:
print(' '.join(map(str,i)))
3. Others' Solutions
import s
n = sys.stdin.readline().rstrip()
res = 0
for i in range(len(n)-1):
res += 9 * (10 ** i) * (i+1)
print(res + ((int(n) - (10 ** (len(n)-1)) + 1) * len(n)))
4. Learned
1. Problem
2. My Solution
import sys
def permutation(level,pre):
if level >= m:
res.append(arr.copy())
else:
for i in range(1, n+1):
if pre < i:
arr[level] = i
else:
continue
permutation(level+1,i)
n, m = map(int,sys.stdin.readline().rstrip().split())
arr = [0] * m
res = []
permutation(0,0)
for i in res:
print(' '.join(map(str,i)))
4. Learned
1. Problem
셀프넘버 복습
2. My Solution
nums = [False] * 10001
for i in range(1,10001):
res = i
for num in list(str(i)):
res += int(num)
if res <= 10000:
nums[res] = True
for i in range(1,10001):
if nums[i] == False:
print(i)
3. Learned
1. Problem
2. My Solution
import sys
n = int(sys.stdin.readline())
if n < 100:
print(n)
exit()
count = 99
for i in range(100,n+1):
diff = set()
for j in range(len(str(i))-1):
diff.add(int(str(i)[j]) - int(str(i)[j+1]))
if len(diff) == 1:
count += 1
print(count)
3. Learned