c++

我会发着呆 发表于 1年前 · 关联问题 球魁

include

using namespace std;

int a(int num) {

if (num <= 2) { return 0; } for (int i = 2; i < num; i++) { if (num % i == 0) { return 1; } } return 0;

}

int main() {

int r, n; int q = 0; cin >> r >> n; if (r % 2 == 0) { q = r / 2; } else { if (n % 2 == 0) { q = (r + 1) / 2; } else { q = (r - 1) / 2; } } int s1, S2, l; int S1 = 0; for (int i = 0; i < q; i++) { cin >> l; if (l == 11) { s1 = 3; } else if (l == 15) { s1 = 0; } else if (a(l) == 0) { s1 = 2; } else if (a(l) == 1) { s1 = 1; } S1 = S1 + s1; } S2 = (r - q) * 2; if (S1 == S2) { cout << "equal."; } else { cout << (S1 > S2 ? "lwh wins." : "lzh wins."); } return 0;

}