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.

AtCoder Beginner Contest 130 解いてみたメモ

Last updated at Posted at 2019-06-16

問題A - Rounding

X,Aは 0以上 9以下の整数です。
Xが A未満の時 0、A以上の時 10を出力してください。

X, A = map(int, input().split())
if X < A:
  print("0")
else:
  print("10")

B - Bounding

# N回跳ねるボール 1≤X≤10000 Xは領域
N, X = map(int, input().split())
# Lははねた距離
length = list(map(int, input().split()))

# バウントしたかず
count_total = 1
# 最初の位置
now = 0
  
for count in range(N):
  #もし領域よりも小さければもう一回跳ねる
  now = now + length[count]
  if now <= X:
    count_total = count_total + 1

print(count_total)
  

C - Rectangle Cutting

#
W, H, x, y = map(int, input().split())

# x,yが図形の半分の位置かどうか
if x == W/2 and y == H/2:
  menseki = W*H/2
  print(menseki,1)
else:
  menseki = W*H/2
  print(menseki,0)

D - Enough Array

# Nのながさと整数 K
N, K = map(int, input().split())
# 列
length = list(map(int, input().split()))

# 合計
sum = 0
# 変わる値
change_number=0
# なんかいやりたいか N(N+1)/2が最大
count =0
largest_count = int(N*(N+1)/2)

count_ans = 0

# すべての部分列のパターンを出す
while count < largest_count:
  for number1 in range(change_number,N):
    sum = sum + length[number1]
    if sum >= K:
      count_ans = count_ans + 1
      
    count = count + 1
  sum = 0
  change_number = change_number + 1

print(count_ans)

計算量で引っかかって最後まで解けなかった・・・くやしい
多分計算量のことをきにしなければ合ってた気がするな。。。

1
0
1

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?