http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0025&lang=jp
#define _USE_MATH_DEFINES #include <iostream> #include <vector> #include <list> #include <cmath> using namespace std; int main () { vector<int> n; int hoge; while (cin >> hoge) { int hit = 0; int brow = 0; n.push_back(hoge); for (int i=0; i < 7; i++) { cin >> hoge; n.push_back(hoge); } for (int i=0; i < 4; i++) { //ヒットの計算 if (n[i] == n[i + 4]) { hit++; } //ブローの計算 for (int j = 4; j < 8; j++) { if (n[i] == n[j]) { brow++; } } } brow -= hit; cout << hit << " " << brow << endl; n.clear(); } return 0; }