解法:
暴力
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
#define endl '\n'
int year(int a) {
int a1 = (a - 3) % 12;
if (a1 == 0)return 12;
else return a1;
}
int tim(int d, int e) {
if (d >= 1 && d < 3) return 2;
else if (d >= 3 && d < 5)return 3;
else if (d >= 5 && d < 7)return 4;
else if (d >= 7 && d < 9)return 5;
else if (d >= 9 && d < 11)return 6;
else if (d >= 11 && d < 13)return 7;
else if (d >= 13 && d < 15)return 8;
else if (d >= 15 && d < 17)return 9;
else if (d >= 17 && d < 19)return 10;
else if (d >= 19 && d < 21)return 11;
else if (d >= 21 && d < 23)return 12;
else return 1;
}
int zhuanhua(int b) {
if (b == 0 || b == 7)return 5;//tu
if (b == 1 || b == 2) return 1;//jin
if (b == 4 || b == 5) return 2;//mu
if (b == 6) return 3;//shui
if (b == 3) return 4;//huo
}
void bagua(int year, int month, int day, int time) {
int s = zhuanhua((year + month + day) % 8);
int x = zhuanhua((year + month + day + time) % 8);
int f = 0;
if (s == 4 && x == 5 || s == 5 && x == 4) f = 1;
if (s == 1 && x == 5 || s == 5 && x == 1) f = 1;
if (s == 1 && x == 3 || s == 3 && x == 1) f = 1;
if (s == 2 && x == 3 || s == 3 && x == 2) f = 1;
if (s == 2 && x == 4 || s == 4 && x == 2) f = 1;
if (s == 1 && x == 4 || s == 4 && x == 1) f = 2;
if (s == 1 && x == 2 || s == 2 && x == 1) f = 2;
if (s == 2 && x == 5 || s == 5 && x == 2) f = 2;
if (s == 3 && x == 5 || s == 5 && x == 3) f = 2;
if (s == 3 && x == 4 || s == 4 && x == 3) f = 2;
if (f == 1) cout << "haoye";
else if (f == 2) cout << "gg";
else cout << "emm";
}
int main() {
int a, b, c, d, e;
cin >> a >> b >> c >> d >> e;
int a1 = year(a);
int d1 = tim(d, e);
bagua(a1, b, c, d1);
return 0;
}