ZOJ-2109
来源:互联网 发布:apache ab 结果分析 编辑:程序博客网 时间:2024/06/04 23:26
好久没刷题了。。这周加班真心累啊,完全木有时间。。以后刷题速度肯定会降下来了,随着题目难度的增加,水题越来越少了,还要分配一些时间到UNIX系统的学习上,但是不能停止,慢慢地前进吧
#include<stdio.h>#include<stdlib.h>struct RoomFood{int javeBean;int catFood;double ratio;};static int cmp(const void *p1, const void *p2){struct RoomFood *r1 = (struct RoomFood*) p1;struct RoomFood *r2 = (struct RoomFood*) p2;if (r1->ratio > r2->ratio)return -1;else if (r2->ratio > r1->ratio)return 1;elsereturn 0;}int main(){int m, n;while (scanf("%d %d", &m, &n), m != -1 && n != -1){struct RoomFood *array = malloc(n * sizeof(struct RoomFood));int i;for (i = 0; i < n; i++){scanf("%d %d", &(array[i].javeBean), &(array[i].catFood));array[i].ratio = array[i].javeBean / (double) array[i].catFood;}qsort(array, n, sizeof(struct RoomFood), cmp);double res = 0;for (i = 0; i < n; i++){if (m > 0){res += m >= array[i].catFood ?array[i].javeBean : array[i].ratio * m;m -= array[i].catFood;}elsebreak;}printf("%.3lf\n", res);free(array);}return 0;}
0 0
- zoj 2109
- zoj 2109
- ZOJ-2109
- ZOJ-2109FatMouse' Trade
- ZOJ 2109 FatMouse' Trade
- zoj 2109 FatMouse' Trade
- ZOJ 2109 FatMouse' Trade
- ZOJ 2109 FatMouse' Trade
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- android App应用的打包及发布
- java单例模式
- I2C和SPI,UART的区别(转)
- HDU 2203 亲和串(KMP:循环移位)
- java单例模式5中实现方法
- ZOJ-2109
- 微软强调Win8.1 Update照顾惯用键鼠用户
- C宏定义中## 和# 的含义
- 数据库冗余数据分析
- 面试-线程的生命周期
- HDU 1037 Keep on Truckin'
- 100万并发连接服务器笔记之测试端就绪
- spring JDBC批量操作
- Junit 多线程测试