#include #include #include #include #include #include using namespace std; // 计算一个数的质因数的最小公倍数 long long lcm(long long a, long long b) { return a / __gcd(a, b) * b; } // 计算一个城堡的完美度 long long calculateCastlePerfectness(const vector>& blocks) { long long product = 1; for (const auto& block : blocks) { product *= pow(block.first, block.second); } return product; } int main() { int n; cin >> n; vector perfectness(n); vector>> castles(n); for (int i = 0; i < n; ++i) { int ti; cin >> ti; castles[i].resize(ti); for (int j = 0; j < ti; ++j) { int Pij, Cij; cin >> Pij >> Cij; castles[i][j] = {Pij, Cij}; } perfectness[i] = calculateCastlePerfectness(castles[i]); } // 计算总完美度 set uniquePerfectness; for (int i = 0; i < n; ++i) { long long currentLcm = 1; for (int j = 0; j < n; ++j) { if (j != i) { currentLcm = lcm(currentLcm, perfectness[j]); } } uniquePerfectness.insert(currentLcm); } // 输出不同的总完美度的种数 cout << uniquePerfectness.size() << endl; return 0; }