TOJ 2988.PLMM
来源:互联网 发布:网络的利与弊征文1000 编辑:程序博客网 时间:2024/06/05 05:48
题目链接 : http://acm.tju.edu.cn/toj/showp2988.html
WCM and ZHC like watching PLMM (beautiful girl). One day they are going to FengHua dining-room for lunch from the second teaching building. You know, there is a straight road lined by many beautiful ginkgos between FengHua dining-room and the second teaching building. WCM and ZHC will not miss this good chance for watching PLMM.
Now they want to know how many PLMM on the road they can meet before they reach FengHua dining-room namely, the end of the road. Assume that they know the position and walking speed of every PLMM on the road at the moment they start.
They think they meet a PLMM if and only if at some time, they and the PLMM are at the same position of the road.
······
这个题虽然很水,但是却很有意思,一方面读题的时候起先以为PLMM是个什么美女相关的节目,继续往下读发现这道题就是两个猥琐男在去食堂的路上看美女,求看了多少美女,于是也恍然大悟,明白了PLMM什么意思。。。又联想到好多同学也有相似的癖好,不禁笑了笑。
言归正传,这道题就是一个相遇问题,很简单,自己写的特别繁琐,其实看了大神的代码发现:
1. 不需要开数组,因为每个美女计算一次就好
2. 所有的情况都可以归结为一条判断if(p*w<=l*(w-s))
,也就是说做题时最好先考虑一般情况,然后再进行边界测试,这样可能代码稍短一些,当然,我是先考虑各种可能情况,一一排除,如果不严谨可能导致没有必要的判断。
#include <stdio.h>using namespace std;int main(){ int cast,sum; double n,l,w,s[10002],p[10002]; scanf("%d",&cast); for(int k=0;k<cast;k++){ sum=0; scanf("%lf%lf%lf",&n,&l,&w); for(int i=0;i<n;i++) scanf("%lf%lf",&p[i],&s[i]); for(int i=0;i<n;i++){ if(s[i]<=0){ sum++; continue; } else if(p[i]==0){ sum++; continue; } else if(p[i]*s[i] <= (l-p[i])*(w-s[i])){ sum++; continue; } } printf("%d\n",sum); }}
- TOJ 2988.PLMM
- PLMM
- 当一辆车撞到一个PLMM
- PLMM整老师
- 爆笑两PLMM买电脑对话全过程
- 爆笑两PLMM买电脑对话全过程
- TOJ 2976
- toj 3140
- toj 1153
- TOJ 1772
- TOJ 3250
- TOJ 3051
- TOJ 4303
- TOJ 1005
- TOJ 1545
- TOJ 2378
- TOJ 1537
- TOJ 1252
- 笔记001--Hashtable/HashMap与key/value为null的关系
- linux本地进程间socket通信是否经过网卡?
- 知道得越多编程越慢怎么办?
- AD2410的使用总结
- 用冒泡法和选择法对10个学生成绩进行排名
- TOJ 2988.PLMM
- HDOJ 2124 Repair the Wall(修城墙,贪心)
- zookeeper客户端四字符指令
- java中length,length(),size()区别 http://blog.csdn.net/sk880609/article/details/7524006
- CCNA系列十二之ACL
- NDK开发总结
- poj题目分类_很有层次感
- 常用的HDFS下的文件命令
- mysql索引和查询优化