1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
| #include <iostream> #include <algorithm> #include<cmath> #include<cstdio> #include<cstring> #include<stack> #include<string> #include<vector> #define ll long long using namespace std; const int N = 100009; ll a[N], b[N], l[] = { 0,1,1,2,6,24 }; int main() { int n, t; scanf("%d%d", &n, &t); for (int i = 0; i < n; i++) scanf("%lld%lld",&a[i], &b[i]); bool f = false; ll z = 0; for (int i = 1; i <= t; i++) { ll sum = 0; for (int j = 0; j < n; j++) { sum += l[i] *pow(-1,i-1)* a[j] * pow(b[j], i); z = sum; } if (sum&&i!=t) { f = true; break; } } ll m = 1; for (int i = 1; i <= t; i++) { m *= i; } if (f) { cout << "infinity" << endl; } else { ll gcd =abs( __gcd(z, m)); if (m/gcd!=1) { cout << z/gcd << '/' << m/gcd << endl; } else { cout << z/gcd << endl; } } return 0; }
|