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

  1. http://acm.hdu.edu.cn/game/entry/problem/list.php?chapterid=1§ionid=3
  1. 1.3.1 FatMouse' Trade
  2. #include <algorithm>
  3. /*
  4. 题意:价值/代价的比值来排序,买比值大的。
  5. Sample Input
  6. 5 3
  7. 7 2
  8. 4 3
  9. 5 2
  10. 20 3 25 18 24 15 15 10 -1 -1
  11.  
  12. Sample Output
  13. 13.333 31.500
  14. */
  15. #include<stdio.h>
  16. #include<stdlib.h>
  17.  
  18. const int MAXN = 1010;
  19. struct node
  20. {
  21. double j,f;
  22. double r;
  23. }a[MAXN];
  24. int cmp(const void *a,const void *b)
  25. {
  26. struct node *c=(node *)a;
  27. struct node *d=(node *)b;
  28. if(c->r > d->r) return -1;
  29. else return 1;
  30. }
  31. int main()
  32. {
  33. int N;
  34. double M;
  35. double ans;
  36. while(scanf("%lf%d",&M,&N))
  37. {
  38. if(M==-1&&N==-1) break;
  39. for(int i=0;i<N;i++)
  40. {
  41. scanf("%lf%lf",&a[i].j,&a[i].f);
  42. a[i].r=(double)a[i].j/a[i].f;
  43. }
  44. qsort(a,N,sizeof(a[0]),cmp);
  45. ans=0;
  46. for(int i=0;i<N;i++)
  47. {
  48. if(M>=a[i].f)
  49. {
  50. ans+=a[i].j;
  51. M-=a[i].f;
  52. }
  53. else
  54. {
  55. ans+=(a[i].j/a[i].f)*M;
  56. break;
  57. }
  58. }
  59. printf("%.3lf\n",ans);
  60. }
  61. return 0;
  62. }
  1. 1.3.2 今年暑假不AC
  2. *
  3. Sample Input
  4. 12
  5. 1 3
  6. 3 4
  7. 0 7
  8. 3 8
  9. 15 19
  10. 15 20
  11. 10 15
  12. 8 18
  13. 6 12
  14. 5 10
  15. 4 14
  16. 2 9
  17. 0
  18.  
  19. Sample Output
  20. 5
  21. */
  22. #include <stdio.h>
  23. #include <stdlib.h>
  24. #include <string.h>
  25.  
  26. struct ti
  27. {
  28. int s, e;
  29. };
  30.  
  31. int compare(const void *a, const void *b);
  32.  
  33. int main()
  34. {
  35. int i, n, k;
  36. struct ti tis[101], temp[101];
  37.  
  38. while(scanf("%d", &n) != EOF)
  39. {
  40. if(n == 0)
  41. break;
  42.  
  43. for(i = 0; i < n; i ++)
  44. {
  45. scanf("%d %d", &tis[i].s, &tis[i].e);
  46. }
  47.  
  48. qsort(tis, n, sizeof(tis[0]), compare);
  49.  
  50. k = 0;
  51. temp[k] = tis[0];
  52.  
  53. for(i = 1; i < n; i ++)
  54. {
  55. if(tis[i].s >= temp[k].e)
  56. temp[++ k] = tis[i];
  57. }
  58. printf("%d\n", k + 1);
  59. }
  60. return 0;
  61. }
  62.  
  63. int compare(const void *a, const void *b)
  64. {
  65. const struct ti *p = (ti*)a;
  66. const struct ti *q = (ti*)b;
  67.  
  68. return p->e - q->e;
  69. }
  1. 1.3.3 排名
  2.  
  3. #include <string>
  4. #include <stdio.h>
  5. #include <algorithm>
  6. using namespace std;
  7. #define N 1000
  8. int que[10];
  9. struct node
  10. {
  11. char name[20];
  12. int num;
  13. int score;
  14. }stu[N];
  15.  
  16. bool cmp(const node& a, const node& b)
  17. {
  18. if (a.score == b.score)
  19. {
  20. return strcmp(a.name, b.name) < 0 ? 1:0;
  21. }
  22. else
  23. {
  24. return a.score > b.score;
  25. }
  26. }
  27.  
  28. /* 联系字典序:第1行给出考生人数N ( 0 < N < 1000 )、考题数M ( 0 < M < = 10 )、分数线(正整数)G;
  29. 第2行排序给出第1题至第M题的正整数分值。
  30. 下面N行,每行给出一名考生准考证号(长度不超过20的字符串)、该生解决的题目总数m、以及这m道题的题号
  31. 4 5 25
  32. 10 10 12 13 15
  33. CS004 3 5 1 3
  34. CS003 5 2 4 1 3 5
  35. CS002 2 1 2
  36. CS001 3 2 3 5
  37. */
  38. int main()
  39. {
  40. int student, question, judge, x, count;
  41. while(scanf("%d", &student),student)
  42. {
  43. count = 0;
  44. for (int i = 1; i <= student;++i)
  45. {
  46. stu[i].score = 0;
  47. stu[i].num = 0;
  48. }
  49. scanf("%d%d",&question, &judge);
  50. for (int i = 1;i <= question;++i)
  51. {
  52. scanf("%d",&que[i]);
  53. }
  54. for (int i = 1;i <= student;++i)
  55. {
  56. scanf("%s%d",&stu[i].name,&stu[i].num);
  57. while(stu[i].num--)
  58. {
  59. scanf("%d",&x);
  60. stu[i].score += que[x];
  61. }
  62. if (stu[i].score >= judge)
  63. count ++;
  64. }
  65. sort(stu+1,stu+1+student,cmp);
  66. printf("%d\n",count);
  67. for (int i = 1;i <= student;++i)
  68. {
  69. if (stu[i].score >= judge)
  70. printf("%s %d\n",stu[i].name, stu[i].score);
  71. else
  72. break;
  73. }
  74. }
  75. return 0;
  76. }

  1. 1.3.4 开门人和关门人
  2. #include "stdafx.h"
  3.  
  4. #include <iostream>
  5. #include <string>
  6. using namespace std ;
  7.  
  8. struct node
  9. {
  10. string name, timee;
  11. }maxt, mint;//记录最大和最小的结构体
  12.  
  13. int main()
  14. {
  15. int t, n;
  16. string s,mis, mas;
  17. cin>>t;
  18.  
  19. while (t--)
  20. {
  21. cin>>n;
  22. n--;
  23. cin>>s>>mint.timee>>maxt.timee;
  24. mint.name = maxt.name = s;
  25.  
  26. while (n--)
  27. {
  28. cin>>s>>mis>>mas;
  29. if (mis < mint.timee)
  30. {
  31. mint.name = s;
  32. mint.timee = mis;
  33. }
  34. if (mas > maxt.timee)
  35. {
  36. maxt.name = s;
  37. maxt.timee = mas;
  38. }
  39. }
  40.  
  41. cout<<mint.name<<" "<<maxt.name<<endl;
  42. }
  43.  
  44. return 0;
  45. }

  1.  

杭电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. 隐藏服务器真实IP的方法来防止DDOS攻击

    2017-08-22 作者:小唐 点击: 10,500次 在无盘系统的环境下,服务器软件存在漏洞,就容易受到DDOS攻击,隐藏服务器真实IP是解决问题最好的方法,下面小编与大家分享一下隐藏服务器真实I ...

  2. C# this.Invoke()的作用与用法

    Invoke()的作用是:在应用程序的主线程上执行指定的委托.一般应用:在辅助线程中修改UI线程( 主线程 )中对象的属性时,调用this.Invoke();   在多线程编程中,我们经常要在工作线程 ...

  3. Java之基本类库学习

    JAVA基本类库: (一),输入相关 main(String[] args):设置输入参数 输入类:Scanner:Scanner sc=new Scanner(System.in); (二),系统相 ...

  4. es创建索引的格式,并初始化数据

    es创建索引的格式,并初始化数据 学习了:https://www.imooc.com/video/15759 1, 创建格式 POST 127.0.0.1:9200/book/novel/_mappi ...

  5. 解决dubbo问题:forbid consumer(2)

    线下环境经常出现类似这种异常: com.alibaba.dubbo.rpc.RpcException: Forbid consumer 10.0.53.69 access service com.ku ...

  6. 《深入理解Android 卷III》第七章 深入理解SystemUI

    <深入理解Android 卷III>即将公布,作者是张大伟.此书填补了深入理解Android Framework卷中的一个主要空白,即Android Framework中和UI相关的部分. ...

  7. MySQL 事件EVENT

    一.用途用于某一时间执行一个事件或周期性执行一个事件. 二.语法CREATE [DEFINER = { user | CURRENT_USER }] EVENT [IF NOT EXISTS] eve ...

  8. 解决log4j.xml问题http//jakarta.apache.org/log4j/ uri is not registered

    在Eclipse中,配置log4j.xml出现"http //jakarta.apache.org/log4j/ uri is not registered"的错误信息. 原始的l ...

  9. 訪问控制 protected, public, private 对照

    OOP 3大特性:数据抽象,继承,动态绑定 3中訪问标号 protected, public, private 对照 用类进行数据抽象:用继承类继承基类的成员,实现继承.通过将基类对应函数声明为vir ...

  10. maven生成jar包

    改了部分cas源码,想重新生成jar包,只好试着脱离eclipse,学了一下maven打jar包的命令,记录如下: 1.首先下载maven (请注意自己的jdk版本,如果使用maven2建议使用jdk ...