筱玛爱地理 逆元

 

 

 

https://ac.nowcoder.com/acm/contest/946/A

#include<bits/stdc++.h>
using namespace std;
const int mod = 1e9+7;
int power(int a, int b, int p)
{
    int ans=1%p;
    for(; b; b>>=1)
    {
        if(b&1) ans=(long long)ans*a%p;
        a=(long long)a*a%p;
    }
    return ans;
}
const int maxn=2e5+10;
struct note
{
    int v,e;
    long double zhi;
} b[maxn];
int a[maxn];
int cmp(note a,note b)
{
    return a.zhi<b.zhi;
}
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1; i<=n; i++)
    {
        int e,v;
        scanf("%d%d",&v,&e);
        long double zhi=(long double)e/v;
        b[i].e=e;
        b[i].v=v;
        b[i].zhi=zhi;
    }
    sort(b+1,b+n+1,cmp);
    for(int i=n;i>=1;i--)
    {
        printf("%d\n",(long long)b[i].e*power(b[i].v,mod-2,mod)%mod);
    }
}

 

posted @ 2019-08-12 13:27  paranoid。  阅读(104)  评论(0编辑  收藏  举报