21. (2019 天津理 19) 设 $\left\{a_{n}\right\}$ 是等差数列, $\left\{b_{n}\right\}$ 是等比数列. 已知 $a_{1}=4, b_{1}=6, b_{2}=2 a_{2}-2, b_{3}=2 a_{3}+4$.

(I) 求 $\left\{a_{n}\right\}$ 和 $\left\{b_{n}\right\}$ 的通项公式;

(II) 设数列 $\left\{c_{n}\right\}$ 满足 $c_{1}=1, c_{n}=\left\{\begin{array}{l}1,2^{k}<n<2^{k+1} \\ b_{k}, n=2^{k},\end{array}\right.$ 其中 $k \in \mathbf{N}^{*}$.

(i) 求数列 $\left\{a_{2^{n}}\left(c_{2^{n}}-1\right)\right\}$ 的通项公式;

(ii) 求 $\sum_{i=1}^{2^{n}} a_{i} c_{i} \quad\left(n \in \mathbf{N}^{*}\right)$.
(I) 设等差数列 $\left\{a_{n}\right\}$ 的公差为 $d$ ，等比数列 $\left\{b_{n}\right\}$ 的公比为 $q$,

依题意得 $\left\{\begin{array}{l}6 q=6+2 d \\ 6 q^{2}=12+4 d\end{array}\right.$, 解得 $\left\{\begin{array}{l}d=3 \\ q=2\end{array}\right.$.

故 $a_{n}=4+(n-1) \times 3=3 n+1, \quad b_{n}=6 \times 2^{n-1}=3 \times 2^{n}$.

所以, $\left\{a_{n}\right\}$ 的通项公式为 $a_{n}=3 n+1\left(n \in \mathbf{N}^{*}\right),\left\{b_{n}\right\}$ 的通项公式为 $b_{n}=3 \times 2^{n}\left(n \in \mathbf{N}^{*}\right)$.

( II ) (i) $a_{2^{n}}\left(c_{2^{n}}-1\right)=a_{2^{n}}\left(b_{n}-1\right)=\left(3 \times 2^{n}+1\right)\left(3 \times 2^{n}-1\right)=9 \times 4^{n}-1$.

所以，数列 $\left\{a_{2^{n}}\left(c_{2^{n}}-1\right)\right\}$ 的通项公式为 $a_{2^{n}}\left(c_{2^{n}}-1\right)=9 \times 4^{n}-1\left(n \in \mathbf{N}^{*}\right)$.

(ii) $\sum_{i=1}^{2^{n}} a_{i} c_{i}=\sum_{i=1}^{2^{n}}\left[a_{i}+a_{i}\left(c_{i}-1\right)\right]=\sum_{i=1}^{2^{n}} a_{i}+\sum_{i=1}^{2^{n}} a_{2^{i}}\left(c_{2^{i}}-1\right)$

$$
\begin{aligned}
& =\left(2^{n} \times 4+\frac{2^{n}\left(2^{n}-1\right)}{2} \times 3\right)+\sum_{i=1}^{n}\left(9 \times 4^{i}-1\right) \\
& =\left(3 \times 2^{2 n-1}+5 \times 2^{n-1}\right)+9 \times \frac{4\left(1-4^{n}\right)}{1-4}-n \\
& =27 \times 2^{2 n-1}+5 \times 2^{n-1}-n-12 \quad\left(n \in \mathbf{N}^{*}\right)
\end{aligned}
$$