Why is it that just looking at the string mathematics makes me lose motivation?
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')
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')
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