#include<iostream>
#include<iostream>
#include<map>
#include<vector>
using namespace std;
int main() {
int h, v;
ios_base::sync_with_stdio(false);
while(cin >> h >> v) {
vector H(h), V(v);
for (int i = 0; i < h; i++) cin >> H[i];
for (int i = 0; i < v; i++) cin >> V[i];
vector difH, difV;
map mapaH, mapaV;
for (int i = 0; i + 1 < h; i++)
for (int j = i + 1; j < h; j++)
mapaH[H[j] - H[i]]++;
for (int i = 0; i + 1 < v; i++)
for (int j = i + 1; j < v; j++)
mapaV[V[j] - V[i]]++;
int ways = 0;
map ::iterator it;
for (it = mapaH.begin(); it != mapaH.end(); it++)
ways += it->second * mapaV[it->first];
cout << ways << endl;
}
return 0;
}
miércoles, 19 de octubre de 2011
Count Square
Suscribirse a:
Enviar comentarios (Atom)
No hay comentarios:
Publicar un comentario