ABC270B-python

x,y,z=map(int, input().split())
if y < 0:
  x=-x
  y=-y
  z=-z
if(x<y):
  print(abs(x))
if(x>y):
  if(y<z):
    print(-1)
  elif(z<0):
    print(x-z*2)
  else:
    print(x)

 

条件分岐めんどくさいな~XYZの位置は、XYZのどれかについて正負どっちかだけのケース考えて反転すればできるって所までは考えられていた。

コーディングとなると出来なくなるから、まだまだ修行が足りん

ABC269B-python

l=[]
a=10**9
b=10**-9
c=10**9
d=10**-9
for i in range(10):
  l.append(input())
for i in range(10):
  for j in range(10):
    if l[i][j] == "#":
      a=min(a,i+1)
      b=max(b,i+1)
      c=min(c,j+1)
      d=max(d,j+1)
print(a, b)
print(c, d)

 

解説見ればなんてことないな~って感じる問題でも、自力だとまだまだできない。

精進せねば

ABC195B-python

a,b,w=map(int,input().split())
min_o=10**9
max_o=0
for i in range (10000001):
  if a*i <= w*1000 and b*i >= w*1000:
    min_o = min(min_o, i)
    max_o = max(max_o, i)
if max_o==0:
  print("UNSATISFIABLE")
else:
  print(min_o,max_o)

 

https://atcoder.jp/contests/abc195/editorial/836

 

上記の記事の解説をほぼ丸パクリの形で参考にした。

 

ABC098B-python

コード

n=int(input())
s=input()
count=0
for i in range(n):
  tmp=0
  a=s[0:i]
  b=s[i:]
  for v,j in enumerate(a):
    if j in b and not j in a[0:v] :
      tmp += 1
  if tmp > count:
    count = tmp
print(count)

 

python君は文字列に対して直接forループ掛けれることを忘れていた。

 

ABC 097B-python

コード

n=int(input())
result=1
for a in range(1,32):
  for b in range(2,10):
    if n < a**b:
      break
    elif n >= a**b and result < a**b:
      result=a**b
print(result)

 

考えたこと

32^2=1024(2^10)より、a^b<=1000の条件下においてaの最大値は31,bの最大値は9。

 

追記

はてなブログってHTMLの知識生かせるんですね。HTMLも勉強しなおしてみようかなあ。