A13050 | Integer Points
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
DLS and JLS are bored with a Math lesson. In order to entertain themselves, DLS took a sheet of paper and drew $n$ distinct lines, given by equations $y = x + p_i$ for some distinct $p_1, p_2, \ldots, p_n$ .
Then JLS drew on the same paper sheet $m$ distinct lines given by equations $y = -x + q_i$ for some distinct $q_1, q_2, \ldots, q_m$ .
DLS and JLS are interested in counting how many line pairs have integer intersection points, i.e. points with both coordinates that are integers. Unfortunately, the lesson will end up soon, so DLS and JLS are asking for your help.
Then JLS drew on the same paper sheet $m$ distinct lines given by equations $y = -x + q_i$ for some distinct $q_1, q_2, \ldots, q_m$ .
DLS and JLS are interested in counting how many line pairs have integer intersection points, i.e. points with both coordinates that are integers. Unfortunately, the lesson will end up soon, so DLS and JLS are asking for your help.
输入格式
The first line contains one integer $t$ ( $1 \le t \le 1000$ ), the number of test cases in the input. Then follow the test case descriptions.
The first line of a test case contains an integer $n$ ( $1 \le n \le 10^5$ ), the number of lines drawn by DLS.
The second line of a test case contains $n$ distinct integers $p_i$ ( $0 \le p_i \le 10^9$ ) describing the lines drawn by DLS. The integer $p_i$ describes a line given by the equation $y = x + p_i$ .
The third line of a test case contains an integer $m$ ( $1 \le m \le 10^5$ ), the number of lines drawn by JLS.
The fourth line of a test case contains $m$ distinct integers $q_i$ ( $0 \le q_i \le 10^9$ ) describing the lines drawn by JLS. The integer $q_i$ describes a line given by the equation $y = -x + q_i$ .
The sum of the values of $n$ over all test cases in the input does not exceed $10^5$ . Similarly, the sum of the values of $m$ over all test cases in the input does not exceed $10^5$ .
In hacks it is allowed to use only one test case in the input, so $t=1$ should be satisfied.
The first line of a test case contains an integer $n$ ( $1 \le n \le 10^5$ ), the number of lines drawn by DLS.
The second line of a test case contains $n$ distinct integers $p_i$ ( $0 \le p_i \le 10^9$ ) describing the lines drawn by DLS. The integer $p_i$ describes a line given by the equation $y = x + p_i$ .
The third line of a test case contains an integer $m$ ( $1 \le m \le 10^5$ ), the number of lines drawn by JLS.
The fourth line of a test case contains $m$ distinct integers $q_i$ ( $0 \le q_i \le 10^9$ ) describing the lines drawn by JLS. The integer $q_i$ describes a line given by the equation $y = -x + q_i$ .
The sum of the values of $n$ over all test cases in the input does not exceed $10^5$ . Similarly, the sum of the values of $m$ over all test cases in the input does not exceed $10^5$ .
In hacks it is allowed to use only one test case in the input, so $t=1$ should be satisfied.
输出格式
For each test case in the input print a single integer — the number of line pairs with integer intersection points.
输入输出样例
输入 #1
3 3 1 3 2 2 0 3 1 1 1 1 1 2 1 1
输出 #1
3 1 0
The picture shows the lines from the first test case of the example. Black circles denote intersection points with integer coordinates.


C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted