您的位置:首页 > 其它

nefu oj 986 林大的入学体检(运算符重载在排序中的运用)

2015-08-01 22:23 411 查看
sum=(sum+m

.a+sum*m

.b)%mod;对应描述当李华刚来到校医院时每个项目要排的时间为ai秒,如果他选择了其中一个项目先排队,那么对于其他的项目每秒增加额外排队时间为bi注意理解

还有 数组开小了就会RE =.=

P.S.本来是单组输入的题多组输入也能过~

bool cmp(time x,time y)

{

return x.a*y.b

}

CE,换了

struct time

{

long long a,b;

bool operator < (const time &other) const

{return a*other.b

}m[100005];

A了~~

全题代码如下

#include

#include

#include

#include

using namespace std;

const int mod=365*24*60*60;

struct time

{

long long a,b;

bool operator < (const time &other) const

{return a*other.b

}m[100005];

long long sum;

int main()

{

//freopen("data.in.txt","r",stdin);

intn,t;

while(~scanf("%d",&t))

{

for(int k=1;k<=t;k++)

{

scanf("%d",&n);

for(int i=0;i

sort(m,m+n);

sum=0;

for(int i=0;i

{

sum=(sum+m

.a+sum*m

.b)%mod;

}

printf("Case #%d: %I64d\n",k,sum);

}

}

return0;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: