watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvY2Fpc2luaV92Yw==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="">

http://acm.hdu.edu.cn/game/entry/problem/list.php?chapterid=1§ionid=3
1.3.1 FatMouse' Trade
#include <algorithm>
/*
题意:价值/代价的比值来排序,买比值大的。
Sample Input
5 3
7 2
4 3
5 2
20 3 25 18 24 15 15 10 -1 -1 Sample Output
13.333 31.500
*/
#include<stdio.h>
#include<stdlib.h> const int MAXN = 1010;
struct node
{
double j,f;
double r;
}a[MAXN];
int cmp(const void *a,const void *b)
{
struct node *c=(node *)a;
struct node *d=(node *)b;
if(c->r > d->r) return -1;
else return 1;
}
int main()
{
int N;
double M;
double ans;
while(scanf("%lf%d",&M,&N))
{
if(M==-1&&N==-1) break;
for(int i=0;i<N;i++)
{
scanf("%lf%lf",&a[i].j,&a[i].f);
a[i].r=(double)a[i].j/a[i].f;
}
qsort(a,N,sizeof(a[0]),cmp);
ans=0;
for(int i=0;i<N;i++)
{
if(M>=a[i].f)
{
ans+=a[i].j;
M-=a[i].f;
}
else
{
ans+=(a[i].j/a[i].f)*M;
break;
}
}
printf("%.3lf\n",ans);
}
return 0;
}
1.3.2	今年暑假不AC
*
Sample Input
12
1 3
3 4
0 7
3 8
15 19
15 20
10 15
8 18
6 12
5 10
4 14
2 9
0 Sample Output
5
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h> struct ti
{
int s, e;
}; int compare(const void *a, const void *b); int main()
{
int i, n, k;
struct ti tis[101], temp[101]; while(scanf("%d", &n) != EOF)
{
if(n == 0)
break; for(i = 0; i < n; i ++)
{
scanf("%d %d", &tis[i].s, &tis[i].e);
} qsort(tis, n, sizeof(tis[0]), compare); k = 0;
temp[k] = tis[0]; for(i = 1; i < n; i ++)
{
if(tis[i].s >= temp[k].e)
temp[++ k] = tis[i];
}
printf("%d\n", k + 1);
}
return 0;
} int compare(const void *a, const void *b)
{
const struct ti *p = (ti*)a;
const struct ti *q = (ti*)b; return p->e - q->e;
}
1.3.3	排名

#include <string>
#include <stdio.h>
#include <algorithm>
using namespace std;
#define N 1000
int que[10];
struct node
{
char name[20];
int num;
int score;
}stu[N]; bool cmp(const node& a, const node& b)
{
if (a.score == b.score)
{
return strcmp(a.name, b.name) < 0 ? 1:0;
}
else
{
return a.score > b.score;
}
} /* 联系字典序:第1行给出考生人数N ( 0 < N < 1000 )、考题数M ( 0 < M < = 10 )、分数线(正整数)G;
第2行排序给出第1题至第M题的正整数分值。
下面N行,每行给出一名考生准考证号(长度不超过20的字符串)、该生解决的题目总数m、以及这m道题的题号
4 5 25
10 10 12 13 15
CS004 3 5 1 3
CS003 5 2 4 1 3 5
CS002 2 1 2
CS001 3 2 3 5
*/
int main()
{
int student, question, judge, x, count;
while(scanf("%d", &student),student)
{
count = 0;
for (int i = 1; i <= student;++i)
{
stu[i].score = 0;
stu[i].num = 0;
}
scanf("%d%d",&question, &judge);
for (int i = 1;i <= question;++i)
{
scanf("%d",&que[i]);
}
for (int i = 1;i <= student;++i)
{
scanf("%s%d",&stu[i].name,&stu[i].num);
while(stu[i].num--)
{
scanf("%d",&x);
stu[i].score += que[x];
}
if (stu[i].score >= judge)
count ++;
}
sort(stu+1,stu+1+student,cmp);
printf("%d\n",count);
for (int i = 1;i <= student;++i)
{
if (stu[i].score >= judge)
printf("%s %d\n",stu[i].name, stu[i].score);
else
break;
}
}
return 0;
}

1.3.4 开门人和关门人
#include "stdafx.h" #include <iostream>
#include <string>
using namespace std ; struct node
{
string name, timee;
}maxt, mint;//记录最大和最小的结构体 int main()
{
int t, n;
string s,mis, mas;
cin>>t; while (t--)
{
cin>>n;
n--;
cin>>s>>mint.timee>>maxt.timee;
mint.name = maxt.name = s; while (n--)
{
cin>>s>>mis>>mas;
if (mis < mint.timee)
{
mint.name = s;
mint.timee = mis;
}
if (mas > maxt.timee)
{
maxt.name = s;
maxt.timee = mas;
}
} cout<<mint.name<<" "<<maxt.name<<endl;
} return 0;
}



杭电OJ(HDU)-ACMSteps-Chapter Three-《FatMouse&#39; Trade》《今年暑假不AC》《排名》《开门人和关门人》的更多相关文章

  1. I题 hdu 1234 开门人和关门人

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1234 开门人和关门人 Time Limit: 2000/1000 MS (Java/Others)   ...

  2. 杭电OJ(HDU)-ACMSteps-Chapter Two-《An Easy Task》《Buildings》《decimal system》《Vowel Counting》

    http://acm.hdu.edu.cn/game/entry/problem/list.php?chapterid=1§ionid=2 1.2.5 #include<stdio.h> ...

  3. HDU 1234 开门人和关门人

    #include <string> #include <algorithm> #include <iostream> using namespace std; st ...

  4. 九度OJ 1013 开门人和关门人

    #include <iostream> #include <string.h> #include <sstream> #include <math.h> ...

  5. HDU 1234:开门人和关门人

    开门人和关门人 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Su ...

  6. 『ACM C++』HDU杭电OJ | 1415 - Jugs (灌水定理引申)

    今天总算开学了,当了班长就是麻烦,明明自己没买书却要带着一波人去领书,那能怎么办呢,只能说我善人心肠哈哈哈,不过我脑子里突然浮起一个念头,大二还要不要继续当这个班委呢,既然已经体验过就可以适当放下了吧 ...

  7. C#利用POST实现杭电oj的AC自动机器人,AC率高达50%~~

    暑假集训虽然很快乐,偶尔也会比较枯燥,,这个时候就需要自娱自乐... 然后看hdu的排行榜发现,除了一些是虚拟测评机的账号以外,有几个都是AC自动机器人 然后发现有一位作者是用网页填表然后按钮模拟,, ...

  8. 用python爬取杭电oj的数据

    暑假集训主要是在杭电oj上面刷题,白天与算法作斗争,晚上望干点自己喜欢的事情! 首先,确定要爬取哪些数据: 如上图所示,题目ID,名称,accepted,submissions,都很有用. 查看源代码 ...

  9. 爬取杭电oj所有题目

    杭电oj并没有反爬 所以直接爬就好了 直接贴源码(参数可改,循环次数可改,存储路径可改) import requests from bs4 import BeautifulSoup import ti ...

随机推荐

  1. Kubernetes 针对资源紧缺处理方式的配置

    如何在资源紧缺的情况下,保证 Node 的稳定性,是 Kubelet 需要面对的一个重要的问题.尤其对于内存和磁盘这种不可压缩的资源,紧缺就相当于不稳定. 在kubelet启动作为参数或者在配置文件中 ...

  2. 资源相互引用时 需添加 PerformSubstitution=True

    获取或设置一个布尔值,该值确定在对由 WebResourceAttribute 类引用的嵌入式资源的处理过程中是否分析其他 Web 资源 URL,并用到该资源的完整路径替换. 如:一个CSS文件引用其 ...

  3. python移植性提示

    移植性提示 2.1 预计在python3.0中,运算符/只能执行True除法.3.0发布后,程序员要更新自己的程序,以兼容新行为. 3.1 python2.0版本开始引入增量赋值符号,在老版本pyth ...

  4. 在scala中:: , +:, :+, :::, +++的区别总结

    初学Scala的人都会被Seq的各种操作符所confuse.下面简单列举一下各个Seq操作符的区别. 4种操作符的区别和联系 :: 该方法被称为cons,意为构造,向队列的头部追加数据,创造新的列表. ...

  5. Selenium-java-Log4j环境搭建

    1.导入Log4j 2.Build Path 3.在/src/main/resource目录下创建文件,命名为 log4j.properties 4.文件的内容是,  直接复制  ### 设置根 定义 ...

  6. configure.ac:8: error: Autoconf version 2.64 or higher is required

    安装Resource Agents的时候出现错误:configure.ac:9: error: Autoconf version 2.63 or higher is required.指的是autoc ...

  7. Oracle基础 自定义函数

    一.函数 函数与存储过程相似,也是数据库中存储的已命名PL-SQL程序块.函数的主要特征是它必须有一个返回值.通过return来指定函数的返回类型.在函数的任何地方可以通过return express ...

  8. 使用C++11封装线程池ThreadPool

    读本文之前,请务必阅读: 使用C++11的function/bind组件封装Thread以及回调函数的使用 Linux组件封装(五)一个生产者消费者问题示例   线程池本质上是一个生产者消费者模型,所 ...

  9. mysql开发之---使用游标双层嵌套对总表进行拆分为帖子表和回复表

    注意点: (1)进行拆分的总表表名是不同的.所以创建暂时表,把总表的数据先插入暂时表 (2)为了避免最外层游标轮询数据结束时,抛出 not found 退出程序,不会运行关闭游标等兴许操作,定义con ...

  10. Linux IO模式及 select、poll、epoll详解(转)

    同步IO和异步IO,阻塞IO和非阻塞IO分别是什么,到底有什么区别?不同的人在不同的上下文下给出的答案是不同的.所以先限定一下本文的上下文. 本文讨论的背景是Linux环境下的network IO. ...