#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; int main() { int i, j; int n1, n2; //vectora, b; vectora, b; int mai1 = 0, mai2 = 0; cin >> n1; for (i = 0; i < n1; i++) { //double num; long long num; cin >> num; a.push_back(num); if (num < 0) mai1++; } cin >> n2; for (i = 0; i < n2; i++) { //double num; long long num; cin >> num; b.push_back(num); if (num < 0) mai2++; } //double ans1 = 0, ans2 = 0; long long ans1 = 0, ans2 = 0; a[0] = abs(a[0]); b[0] = abs(b[0]); if (n2 >= 2) { for (i = b.size() - 1; i >= 1; i--) { //a[0] *= b[i]; a[0] *= abs( b[i]); } } if (n1 >= 2) { for (i = a.size() - 1; i >= 1; i--) { //b[0] *= a[i]; b[0] *= abs( a[i]); } } vectorslist{ 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83 ,89 ,97 ,101 ,103 ,107 ,109 ,113 ,127 ,131 ,137 ,139 ,149 ,151 ,157 ,163 ,167 ,173 ,179 ,181 ,191 ,193 ,197 ,199 ,211 ,223 ,227 ,229 ,233 ,239 ,241 ,251 ,257 ,263 ,269 ,271 ,277 ,281 }; while (true) { bool flag = false; for (i = 0; i < slist.size(); i++) { if (a[0] % slist[i] == 0 && b[0] % slist[i] == 0) { a[0] /= slist[i]; b[0] /= slist[i]; flag = true; } } if (flag == false) break; } if (mai1 % 2 == 0) { mai1 = 0; } else { mai1 = 1; } if (mai2 % 2 == 0) { mai2 = 0; } else { mai2 = 1; } if (mai1 == 1) { a[0] = 0 - abs(a[0]); } if (mai2 == 1) { b[0] = 0 - abs(b[0]); } cout << a[0] << " " << b[0] << endl; //if (n1 == 1) { // ans1 = a[0]; //} //else { // ans1 = a[0]; // for (i = 1; i < n1; i++) { // //ans1 = a[i] / a[i + 1]; // ans1 = ans1 / a[i]; // } //} //if (n2 == 1) { // ans2 = b[0]; //} //else { // ans2 = b[0]; // for (i = 1; i < n2; i++) { // //ans2 = b[i] / b[i + 1]; // ans2 = ans2 / b[i]; // } //} //double ans3 = (ans1 / ans2); //cout << ans3 << " " << 1 << endl; getchar(); getchar(); return 0; }