- 子矩形计数
#include <iostream>
#include <cmath>
using namespace std;
int a[40041], b[40041];
//int num1[40041],num2[40041];
pair<int, int> f[40041];
int main()
{int n, m, k;int num;cin >> n >> m >> k;int cou1 = 0, cou2 = 0;for (int i = 1; i <= n; i++) //找大矩阵的长和宽{cin >> num;if (num){cou1++;a[cou1]++;}elsecou1 = 0;}for (int i=n;i>1;i--) a[i-1]+=a[i];for (int i = 1; i <= m; i++){cin >> num;if (num){cou2++;b[cou2]++;}elsecou2 = 0;}for (int i = m;i>1;i--) b[i-1]+=b[i];// int len = 0;// for (int i = 1; i <= sqrt(k); i++) //找到子矩阵的长和宽// {// if ((int)(k / i) * i == k)// {// f[len].first = i;// f[len].second = k / i;// len++;// }// }long long sum = 0;for (int i=1;i<=k&&i<=n;i++){if(k%i==0&&k/i<=m)sum+=a[i]*b[k/i];}// for (int i = 1; i < len1; i++)//超时算法// {// for (int j = 1; j < len2; j++)// {// for (int h = 0; h < len; h++)// {// int chang = f[h].first;// int kuang = f[h].second;// if (a[i] >= chang && b[i] >= kuang)// sum += (a[i] - chang + 1) * (b[i] - kuang + 1);// if (b[i] >= chang && a[i] >= kuang)// sum += (b[i] - chang + 1) * (a[i] - kuang + 1);// }// }// }cout << sum << endl;
}