#P12409. 嗦面

嗦面

背景

他们曾如此骄傲地……

题目描述

给你 nn 根面条,长度为 {l1,l2,l3,⋯ ,ln}\{l_1,l_2,l_3,\cdots,l_n\},你可以进行若干次以下操作:

  • 选取一根长度为偶数的面条,把它平均切成两根面条。

有 mm 次询问(每次询问独立):

  • a b c d e f:请判断能否切完面条后让面条长度的乘积等于 $R=2^a\times3^b\times5^c\times7^d\times11^e\times13^f$;若能则输出 1,否则输出 0。

输入格式

共 2+m2+m 行。

第一行 22 个正整数,分别为 nn 和 mm,含义见题面。

第二行 nn 个正整数,分别为 l1,l2,l3,⋯ ,lnl_1,l_2,l_3,\cdots,l_n,含义见题面。

第 3∼2+m3\sim 2+m 行每行 66 个非负整数,分别为 a,b,c,d,e,fa,b,c,d,e,f,含义见题面。

输出格式

共 mm 行。

第 1∼m1\sim m 行,每行输出 1 或 0,含义见题面。

6 4
2 4 6 12 9 11
6 4 0 0 1 0 
5 5 0 0 1 0
0 8 0 0 1 0
0 8 0 0 2 0
1
1
1
0

提示

数据:

$R=2^a\times3^b\times5^c\times7^d\times11^e\times13^f$ | Subtask | nn | lil_i | a,b,c,d,e,fa,b,c,d,e,f | RR | pts | | :----------: | :----------: | :----------: | :----------: | :----------: | :----------: | | 00 | ≤10\le10 | 1≤li≤131\le l_i\le13 | ≤80\le80 | ≤106\le10^6 | 1010 | | 11 | ≤10\le10 | 1≤li≤131\le l_i\le13 | ≤10\le10 | 无特殊限制 | 1010 | | 22 | ≤80\le80 | 1≤li≤131\le l_i\le13 | ≤80\le80 | 无特殊限制 | 2020 | | 33 | ≤105\le10^5 | 1≤li≤131\le l_i\le13 | ≤4×105\le4\times10^5 | 无特殊限制 | 6060 |

对于所有数据,1≤n≤1051\le n\le 10^5,1≤li≤131\le l_i\le 13,1≤m≤1051\le m\le10^5,0≤a,b,c,d,e,f≤4×1050\le a,b,c,d,e,f\le4\times10^5。