HDU 4442 贪心
来源:互联网 发布:base64解码 js 编辑:程序博客网 时间:2024/05/22 15:23
给出N个数,和每个数的a,b值
贪心思想,按a/b排序放置即可;
#include "stdio.h"#include "string.h"#include "algorithm"using namespace std;struct node{ int a,b; double c;}data[100010];__int64 inf=99999999999999;__int64 Mod=365*24*60*60;bool cmp(node a,node b){ return a.c<b.c;}int main(){ int n,i; __int64 ans,temp; while (scanf("%d",&n)!=EOF) { if (n==0) break; for (i=0;i<n;i++) { scanf("%d%d",&data[i].a,&data[i].b); if (data[i].b==0) data[i].c=inf; else data[i].c=1.0*data[i].a/data[i].b*1.0; } sort(data,data+n,cmp); ans=temp=0; for (i=0;i<n;i++) { temp=ans; temp*=data[i].b; temp+=data[i].a; ans+=temp; ans%=Mod; } printf("%I64d\n",ans); } return 0;}
1 0
- HDU 4442 贪心
- hdu 4442 贪心
- HDU 4442 排队贪心
- 贪心--HDU - 4442 Physical Examination
- HDU 4442 Physical Examination (贪心)
- 贪心算法(hdu 4442 hdu 3183)
- HDU 贪心
- 【贪心】hdu
- hdu 4442 贪心(交换排序)
- HDU-#4442 Physical Examination(贪心)
- hdu 4442 Physical Examination(贪心)
- HDU 4442 - Physical Examination(贪心)
- hdu 4442 Physical Examination(贪心)
- HDU 4442 Physical Examination (贪心选择)
- HDU 4442 Physical Examination(贪心)
- hdu 4442 Physical Examination (贪心)
- HDU 2111 Saving HDU(贪心)
- HDU 2111贪心--【Saving HDU】
- 利用HashMap存取对象
- CentOS6.5下用Git克隆代码(https方式)
- 单页网站如何做SEO优化排名呢
- 以英文逗点 , 分割的手机号 正则写法
- Centos搭建SVN服务器三步曲
- HDU 4442 贪心
- <!DOCTYPE html>很重要
- Linux kernel boot process——从实模式(real mode)到保护模式(protected mode),再到分页(paging)
- hdu 4442 Physical Examination (排序)
- 这样真的可以吗
- 为ffmpeg添加自定义滤镜
- js的位运算符
- Android——HttpClient 实现POST和Get请求,Connection链接
- JSP中使用哪种输出方式更好?