1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

A - F, C - Travel, C - Buy an Integer

1
Last updated at Posted at 2021-02-12

2021/2/11
くじかつ、精進内容。

A - F

O(1)

python
a, b = list(map(int, input().split()))
 
if a + b == 15:
  print("+")
elif a * b == 15:
  print("*")
else:
  print("x")

C - Travel

計算量はパッと思い浮かばない。。。
順列全探索ですね。

python
import itertools
 
N, K = list(map(int, input().split()))
T = [[] for _ in range(N)]
 
for i in range(0, N):
        T[i] = list(map(int, input().split()))
 
l = [0] * N
for i in range(0, N):
    l[i] = i
 
res = 0
for p in itertools.permutations(l):
    sum = 0
    for i in range(1, N):
        if p[0] > 0:
            continue
        y = p[i]
        x = p[i-1]
        sum += T[x][y]
        if i == N-1:
            sum += T[y][0]
 
    if sum == K:
        res += 1
 
print(res)

C - Buy an Integer

O(NlogN)
二分探索

python
import math
import itertools
 
A, B, X = list(map(int, input().split()))
 
left = 0
right = 1000000001
 
while right-left > 1:
    mid = (right + left) // 2
    if A*mid + B*len(str(mid)) > X:
        right = mid
    else:
        left = mid
        
print(left)

まとめ

緑diffは勉強してない分野と判断。
3完走で撤退し余った時間を勉強に当てました。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?