結果
問題 | No.1810 RGB Biscuits |
ユーザー | customaddone |
提出日時 | 2022-01-14 22:19:35 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 152 ms / 2,000 ms |
コード長 | 2,084 bytes |
コンパイル時間 | 464 ms |
コンパイル使用メモリ | 82,768 KB |
実行使用メモリ | 78,880 KB |
最終ジャッジ日時 | 2024-11-20 11:36:25 |
合計ジャッジ時間 | 3,617 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 58 ms
65,152 KB |
testcase_01 | AC | 63 ms
66,944 KB |
testcase_02 | AC | 59 ms
65,408 KB |
testcase_03 | AC | 77 ms
72,960 KB |
testcase_04 | AC | 79 ms
73,728 KB |
testcase_05 | AC | 128 ms
77,920 KB |
testcase_06 | AC | 152 ms
78,208 KB |
testcase_07 | AC | 147 ms
78,880 KB |
testcase_08 | AC | 150 ms
78,236 KB |
testcase_09 | AC | 148 ms
78,208 KB |
testcase_10 | AC | 137 ms
78,080 KB |
testcase_11 | AC | 72 ms
70,272 KB |
testcase_12 | AC | 88 ms
77,568 KB |
testcase_13 | AC | 88 ms
77,612 KB |
testcase_14 | AC | 115 ms
78,156 KB |
testcase_15 | AC | 93 ms
77,696 KB |
testcase_16 | AC | 98 ms
77,824 KB |
testcase_17 | AC | 135 ms
78,336 KB |
testcase_18 | AC | 132 ms
78,208 KB |
testcase_19 | AC | 72 ms
71,168 KB |
testcase_20 | AC | 58 ms
65,280 KB |
testcase_21 | AC | 107 ms
78,052 KB |
ソースコード
from collections import defaultdict, deque, Counter from heapq import heapify, heappop, heappush import math from copy import deepcopy from itertools import combinations, permutations, product, combinations_with_replacement from bisect import bisect_left, bisect_right import sys def input(): return sys.stdin.readline().rstrip() def getN(): return int(input()) def getNM(): return map(int, input().split()) def getList(): return list(map(int, input().split())) def getListGraph(): return list(map(lambda x:int(x) - 1, input().split())) def getArray(intn): return [int(input()) for i in range(intn)] mod = 10 ** 9 + 7 MOD = 998244353 # sys.setrecursionlimit(10000000) inf = float('inf') eps = 10 ** (-15) dy = [0, 1, 0, -1] dx = [1, 0, -1, 0] ############# # Main Code # ############# def array_cnt(ar1, ar2, m): h = len(ar1) w = len(ar2[0]) row = ar1 col = [] for j in range(w): opt = [] for i in range(len(ar2)): opt.append(ar2[i][j]) col.append(opt) res = [[[0, 0] for i in range(w)] for i in range(h)] for i in range(h): for j in range(w): cnt = 0 for x, y in zip(row[i], col[j]): cnt += x * y res[i][j] = cnt res[i][j] %= m return res """ R, G, B 操作1,操作2,操作1... 操作1 [[1, 0, A], [0, 1, B], [0, 0, 1]] R, G, B + (R + G) 操作2 [[0, 1, 0], [0, 0, 0], [1, 0, 0]] これをmixする """ A, B = getNM() odd = [[1, 0, A], [0, 1, B], [0, 0, 1]] even = [[0, 1, 0], [0, 0, 0], [1, 0, 0]] mix = array_cnt(odd, even, mod) T = getN() k = 10 ** 20 # たくさん! logk = k.bit_length() dp = [[[0] * 3 for j in range(3)] for i in range(logk)] dp[0] = mix for i in range(1, logk): dp[i] = array_cnt(dp[i - 1], dp[i - 1], mod) for _ in range(T): t = getN() mi_t = t // 2 ans = [[1, 1, 0]] for i in range(mi_t.bit_length()): if mi_t & (1 << i): ans = array_cnt(ans, dp[i], mod) if t % 2 == 1: ans = array_cnt(ans, odd, mod) print(sum(ans[0]) % mod)