1 条题解
-
0
202502cj14周子祥 (周子祥) LV 8 @ 2025-03-21 19:18:21
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
using namespace std;
#define pii pair<int, int>
#define fi first
#define se second
#define piii pair<int, pii >
const int maxn = 1000 + 2, Len = 4000 + 1, base = 10000;
struct bint
{
int len;
int v[Len];
bint(int r = 0) {for (len = 0; r > 0; r /= base) v[len++] = r % base;}
bint &operator = (const bint &a)
{
memcpy(this, &a, sizeof(int) * (a.len + 1));
return *this;
}
bool operator < (const bint &a)
{
if (len != a.len) return len < a.len;
for (int i = len - 1; i >= 0; i--)
if (v[i] != a.v[i]) return v[i] < a.v[i];
return false;
}
};
ostream &operator << (ostream &out, const bint &a)
{
printf("%d", a.len == 0 ? 0 : a.v[a.len - 1]);
for (int i = a.len - 2; i >= 0; i--) printf("%04d", a.v[i]);
return out;
}
bint operator * (const bint &a, const int &b)
{
bint ans = 0;
if (!a.len || !b) return ans;
int carry = 0, i;
for (i = 0; i < a.len || carry; i++)
{
if (i < a.len) carry += a.v[i] * b;
ans.v[i] = carry % base;
carry /= base;
}
ans.len = i;
return ans;
}
bint operator / (const bint &a, const int &b)
{
bint ans = a;
int carry = 0;
for (int i = ans.len - 1; i >= 0; i--)
{
ans.v[i] += carry * base;
carry = ans.v[i] % b;
ans.v[i] /= b;
}
while (!ans.v[ans.len - 1] && ans.len) ans.len--;
return ans;
}
inline void gmax(bint &a, const bint &b) {if (a < b) a = b;}
int n, a, b;
piii d[maxn];
int main()
{
scanf("%d%d%d", &n, &a, &b);
for (int i = 1; i <= n; i++)
scanf("%d%d", &d[i].se.fi, &d[i].se.se), d[i].fi = d[i].se.fi * d[i].se.se;
sort(d + 1, d + n + 1);
bint to = a, ans = 0;
for (int i = 1; i <= n; i++)
{
gmax(ans, to / d[i].se.se);
to = to * d[i].se.fi;
}
cout << ans << endl;
return 0;
}
- 1