[PYTHON] yukicoder contest 266 Participation record

yukicoder contest 266 Participation record

A 1229 Rugby scoring pattern

Since N ≤ 100, there is no problem with the full search, so you only have to pay attention to "Because the conversion is a kick after trying, so be sure to make it less than the number of tries".

N = int(input())

result = 0
for i in range(N // 5 + 1):
    for j in range(i + 1):
        for k in range(N // 3 + 1):
            if i * 5 + j * 2 + k * 3 == N:
                result += 1
print(result)

B 1230 Hall_and_me

All the probabilities should be calculated and the maximum value should be taken. If the probability that a diamond is contained in a treasure box is x, it will be the probability x when it is in the case of STAY, and when it is not in the case of CHANGE. (Because you can open the treasure chest of the lost that you did not specify, if it is not in the specified treasure chest, it will be a treasure chest that definitely contains the CHANGE destination), so the probability is 1 --x.

P, Q, R = map(int, input().split())

a = P / (P + Q + R)
b = Q / (P + Q + R)
c = R / (P + Q + R)

print(max(a, b, c, 1 - a, 1 - b, 1 - c))

C 1231 Make a Multiple of Ten

Typical problem of DP. For each card not taken, the remainder obtained by dividing the sum of the integers written on the cards by 10 is used as the index, the number of cards taken is used as the value, and the maximum number of cards taken is taken. Just do DP.

N, *A = map(int, open(0).read().split())

dp = [-1] * 10
dp[0] = 0
for a in A:
    t = [-1] * 10
    for i in range(10):
        if dp[i] == -1:
            continue
        if t[i] < dp[i]:
            t[i] = dp[i]
        n = (i + a) % 10
        if t[n] < dp[i] + 1:
            t[n] = dp[i] + 1
    dp = t
print(dp[0])

D 1232 2^x = x

From Fermat's Little Theorem, a p-1 </ sup> ≡ 1 (mod p), so a (p-1) 2 </ sup> </ sup> ≡ 1 (mod p) However, (p-1) 2 </ sup> = p 2 </ sup> -2p + 1≡1 (mod p), so (p-1) 2 </ sup> Is generally the answer. Fermat's little theorem has the condition that a and p are mutually prime, so this answer cannot be used only for p = 2, but the answer for 2 is in the sample.

N, *p = map(int, open(0).read().split())

for x in p:
    if x == 2:
        print(2)
    else:
        print((x - 1) * (x - 1))

Recommended Posts

yukicoder contest 265 Participation record
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 271 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 264 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