yukicoder contest 251 Participation record

yukicoder contest 251 Participation record

A 1070 Missing a space

You can't start with 0, so you can subtract that much.

C = input()

print(len(C) - 1 - C.count('0'))

B 1071 Behomaler

First of all, if Behomalar consumes less MP, all Behomalar is fine. Also, if Behomaler consumes more MP than Behomaler N times, all Behomaler is fine. The problem is in the middle, for example, Behomaler. If the memory consumption of is twice that of Behomalar, the person other than the one with the highest HP will be recovered with Behomalar, and when it is finished, the remaining one will be recovered with Behomalar. It is the same whether it is 1.1 times or 1.9 times. If it is 2.1 times, it will recover with Behomalar except for those who have the first and second highest HP, and when it is over, the remaining two people who have not finished recovering will be recovered with Behoimi. Behomaler's memory consumption is ceil, which is the magnification of Behoimi. Note that the initial HP is 1.

from math import ceil

N, K, X, Y = map(int, input().split())
A = list(map(int, input().split()))

B = [((a - 1) + K - 1) // K for a in A]
B.sort(reverse=True)

if Y <= X:
    print(Y * B[0])
    exit()
t = ceil(Y / X) - 1
if t < N:
    print(Y * B[t] + X * sum(B[i] - B[t] for i in range(t)))
else:
    print(X * sum(B[i] for i in range(N)))

C 1072 A Nice XOR Pair

Count each number of A and add up the product of each number of A and A xor X. When A or X, it becomes a pair with A and becomes a double count, so the last 2 You can divide by. However, it is special only when X = 0, and it will be combined with itself with A xor 0 = A, so only in that case number of A </ sub> C 2 </ strong> Sub> is summed.

N, X = map(int, input().split())
A = [int(input()) for _ in range(N)]

d = {}
for a in A:
    d.setdefault(a, 0)
    d[a] += 1

result = 0
if X == 0:
    for v in d.values():
        result += v * (v - 1) // 2
    print(result)
else:
    for k in d:
        if k ^ X in d:
            result += d[k] * d[k ^ X]
    print(result // 2)

D 1073 Infinite Sugoroku

Lost. I can write that it is naive. N ≤ 10 18 </ sup> is impossible, isn't it?

Recommended Posts

yukicoder contest 266 Participation record
yukicoder contest 263 Participation record
yukicoder contest 243 Participation record
yukicoder contest 273 Participation record
yukicoder contest 252 Participation record
yukicoder contest 259 Participation record
yukicoder contest 249 Participation record
yukicoder contest 251 Participation record
yukicoder contest 242 Participation record
yukicoder contest 241 Participation record
yukicoder contest 277 Participation record
yukicoder contest 257 Participation record
yukicoder contest 254 Participation record
yukicoder contest 246 Participation record
yukicoder contest 275 Participation record
yukicoder contest 274 Participation record
yukicoder contest 247 Participation record
yukicoder contest 261 Participation record
yukicoder contest 278 Participation record
yukicoder contest 248 Participation record
yukicoder contest 270 (mathematics contest) Participation record
yukicoder contest 272 (Weird math contest) Participation record
yukicoder contest 256 entry record
yukicoder contest 267 entry record
yukicoder contest 264 entry record
yukicoder contest 245 entry record
yukicoder contest 250 entry record
yukicoder contest 262 entry record
yukicoder contest 259 Review
yukicoder contest 261 Review
yukicoder contest 267 Review
yukicoder contest 266 Review
yukicoder contest 263 Review
yukicoder contest 268 Review
AtCoder Beginner Contest 181 Participation Report
AtCoder Beginner Contest 161 Participation Report
AtCoder Beginner Contest 151 Participation Report
AtCoder Beginner Contest 176 Participation Report
AtCoder Beginner Contest 154 Participation Report
AtCoder Beginner Contest # 003 Participation Note
AtCoder Grand Contest 041 Participation Report
AtCoder Beginner Contest 166 Participation Report
AtCoder Grand Contest 040 Participation Report
AtCoder Beginner Contest 153 Participation Report
AtCoder Beginner Contest 145 Participation Report
AtCoder Beginner Contest 184 Participation Report
AtCoder Beginner Contest 165 Participation Report
AtCoder Beginner Contest 160 Participation Report
AtCoder Beginner Contest 169 Participation Report
AtCoder Beginner Contest 178 Participation Report
AtCoder Beginner Contest 163 Participation Report
AtCoder Beginner Contest 159 Participation Report
AtCoder Beginner Contest 164 Participation Report
AtCoder Regular Contest 105 Participation Report
AtCoder Beginner Contest 168 Participation Report
AtCoder Beginner Contest 150 Participation Report
AtCoder Beginner Contest 158 Participation Report
AtCoder Beginner Contest 180 Participation Report
AtCoder Regular Contest 104 Participation Report
AtCoder Beginner Contest 156 Participation Report
AtCoder Beginner Contest 162 Participation Report