HDU 4442 Physical Examination

 
#include<iostream>
#include<cstdio>
#include<algorithm>
#define MAXSIZE 1000030
using namespace std;
struct node
{
    __int64 a,b;
}P[MAXSIZE];
__int64 s,sum;
bool cmp(node a,node b)
{
    return a.a*b.b<a.b*b.a;
}

int main()
{
    int n;
    __int64 MOD=365*24*60*60;
    while(scanf("%d",&n),n)
    {
        for(int i=0;i<n;i++)
        {
            scanf("%I64d%I64d",&P[i].a,&P[i].b);

        }
        sort(P,P+n,cmp);
        sum=0;s=0;
        for(int i=0;i<n;i++)
        {

            s=P[i].a+sum*P[i].b;
            sum+=s;
           sum=sum%MOD;
        }

        cout<<sum%MOD<<endl;

    }
    return 0;
}

你可能感兴趣的:(HDU 4442 Physical Examination)