Infinite Array
时间限制:C/C++/Rust/Pascal 2秒,其他语言4秒
空间限制:C/C++/Rust/Pascal 512 M,其他语言1024 M
64bit IO Format: %lld

题目描述

You are given two arrays and , which has infinite length.
The first elements of is a_1,a_2,...,a_n . If , there is always .
The first elements of is b_1,b_2,...,b_m . If , there is always .
It is guaranteed that (gcd: the greatest common divisor).
You are given an integer , you should find how many satisfy .

输入描述:

The first line of the input contains three integer  ,  , meaning as shown above.
The second line contains integers .
The third line contains integers .

输出描述:

The output contains an integer, representing the answer.
示例1

输入

复制
3 5 9
2 4 10
3 5 8 1 4

输出

复制
4

说明

For the first example:
The array a_{} is [2,4,10,2,4,10,2,4,10,2,...]_{} .
The array b_{} is [3,5,8,1,4,3,5,8,1,4,3,5,...]_{} .
There are 4_{} positions where a_i>b_i\ (i\in \{3,4,6,9\}) .
示例2

输入

复制
5 6 1919810
1 2 3 4 5
1 1 4 5 1 4

输出

复制
895912