无高精度已60,写了坑坑巴巴的高精度目前只过1,2, 求助各位大佬
#include<bits/stdc++.h>
using namespace std;
const int M = 4010;
struct eee {
int l;
int r;
} a[10005];
int n, l1, r1; //初始左右手
int num[M], ans[M], tmp[M] = {1}, ttmp[M]; //左手乘积,答案,临时数组
bool is(eee x, eee y)
{
return x.l * x.r < y.l * y.r;
}
void P_multiplication(int p[M], int y) //高乘单
{
//乘
for (int i = M - 1; i >= 0; i--) p[i] *= y;
for (int i = 0; i < M; i++) {
//进位
p[i + 1] += (p[i] / 10);
p[i] %= 10;
}
}
void Pcopy(int p[M],int v[M])
{
for (int i = M - 1; i >= 0; i--) v[i] = p[i];
}
void P_division(int p[M], int b[M], int y) //高除单
{
for (int i = M - 1; i >= 0; i--) {
if (p[i] < y) {
p[i - 1] += 10 * p[i];
p[i] = 0;
b[i] = 0;
} else {
b[i] = p[i] / y;
p[i - 1] += 10 * (p[i] % 10);
}
}
}
bool compare(int v[M], int b[M]) //比较
{
for (int i = M ; i >= 0; i--) {
if (v[i] > b[i]) {
return 1;
break;
} //1:v比b大 2:v比b小
if (v[i] < b[i]) {
return 0;
break;
}
}
return 0;
}
void pcout(int v[M])//输出
{
bool eep = 0;
for (int i = M-1 ; i >= 0; i--) {
if (v[i]) {
eep = 1;
}
if (eep == 1) cout << v[i];
}
}
int main()
{
cin >> n >> l1 >> r1;
for (int i = 1; i <= n; i++) cin >> a[i].l >> a[i].r;
sort(a + 1, a + 1 + n, is);
/*for (int i = 1; i <= n; i++) cout<< a[i].l << a[i].r;
return 0;*/
//对l1做预处理
P_multiplication(tmp, l1);
for (int i = 1; i <= n; i++) {
int tttmp[M];
Pcopy(tmp,tttmp);
P_division(tmp, ttmp, a[i].r);
Pcopy(tttmp,tmp);
P_multiplication(tmp, a[i].l);
if (compare(ttmp, ans)) Pcopy(ttmp, ans);
memset(ttmp, 0, sizeof(ttmp));
}
pcout(ans);
return 0;
}