90求助
查看原帖
90求助
1024213
albertting楼主2024/10/2 18:20
#include <bits/stdc++.h>
using namespace std;

int n;
struct person{
    int x, y;
} a[100005];
int t[100005], top = 1;

void times(int x)
{
    int num = 0;
    for(int i = 1; i <= top; i++)
    {
        num += x * t[i];
        t[i] = num % 10;
        num /= 10;
    }
    while(num)
    {
        t[++top] = num % 10;
        num /= 10;
    }
}

void div(int x)
{
    int num = 0;
    for(int i = top; i >= 1; i--)
    {
        num = num * 10 + t[i];
        if(num >= x)
        {
            t[i] = num / x;
            num %= x;
        }
        else t[i] = 0;
    }
}

void print()
{
    for(top; t[top] == 0; top--);
    for(int i = top; i >= 1; i--)
    {
        printf("%d", t[i]);
    }
}

bool cmp(person b, person c)
{
    return b.x * b.y < c.x * c.y;
}

int main()
{
    scanf("%d", &n);
    for(int i = 1; i <= n + 1; i++)
        scanf("%d %d", &a[i].x, &a[i].y);
    sort(a + 2, a + n + 2, cmp);
    t[1] = 1;
    for(int i = 1; i <= n; i++)
    {
        times(a[i].x);
    }
    div(a[n + 1].y);
    print();
    return 0;
}

悬棺qwq

2024/10/2 18:20
加载中...