yukicoder contest 270 (mathematics contest) Participation record

yukicoder contest 270 (mathematics contest) Participation record

Why is it that just looking at the string mathematics makes me lose motivation?

A 1256 continuous integer sequence

Consider a continuous integer sequence of length 3. 0 + 1 + 2 = 3 can be + 3n, so any multiple of 3 can be generated. A similar integer sequence of length 4 is 4n + 2, length 5 It can be seen that 5n can be generated for the integer sequence of, and 6n + 3 can be generated for the integer sequence of length 6. In summary, the integer sequence of length n is a multiple of n when n is odd, and n is even. It can be seen that a multiple of n + (n / 2) can be generated at.

In other words, if A is even, it can always be generated by a continuous integer sequence of length 2A. If A is odd, it can always be generated by a continuous integer sequence of length A or length 2A. By the way, due to the limitation of the problem, the length can be generated. Since a sequence of consecutive integers of 1 and 2 cannot be used, only 1 is an integer that cannot be generated.

A = int(input())

if A == 1:
    print('NO')
else:
    print('YES')

B 1257 strange mean

If you do operation 1 only once, it will not be an integer and will never match. However, if you do it twice, it will return to the original value. Then, since only 2 can be used, A, B, C and D, If the integers that make up E and F just change the order, you only have to do step 2 once with'Yes', otherwise you get'No'.

A, B, C = map(int, input().split())
D, E, F = map(int, input().split())

if sorted([A, B, C]) == sorted([D, E, F]):
    print('Yes')
    print(2)
else:
    print('No')

C 1258 Coin Game

What you want is N </ sub> C 0 </ sub> M 0 </ sup> + N </ sub> C 2 </ strong> when X = 0 sub> M 2 </ sup> + ..., and when X = 1, N </ sub> C 1 </ sub> M 1 </ sup> + N </ sub> C 3 </ sub> M 3 </ sup> + ... By the way (M + 1) N </ sup> = N </ sub> C N </ sub> M N </ sup> + N </ sub> C N-1 </ sub> M N- 1 </ sup> + ... + N </ sub> C 0 </ sub> M 0 </ sup> (M-1) N </ sup> > = N </ sub> C N </ sub> M N </ sup>- N </ sub> C N-1 </ sub> M < From sup> N-1 </ sup> + ..., we can calculate what we can find from (M + 1) N </ sup> and (M-1) N </ sup>.

from sys import stdin

readline = stdin.readline
m = 1000000007

S = int(readline())
div2 = pow(2, m - 2, m)
for _ in range(S):
    N, M, X = map(int, readline().split())
    a = pow(M + 1, N, m)
    b = pow(M - 1, N, m)
    if (N + X) % 2 == 0:
        print((a + b) * div2 % m)
    else:
        print((a - b) * div2 % m)

Recommended Posts

yukicoder contest 270 (mathematics contest) Participation record
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 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 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 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 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 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
AtCoder Beginner Contest 157 Participation Report
AtCoder Beginner Contest 167 Participation Report