poj 1492 Up and Down Sequences 模拟计数
来源:互联网 发布:mysql入门经典 电子书 编辑:程序博客网 时间:2024/06/04 18:31
水题,直接贴代码。
//poj 1492 //sep9#include <iostream>using namespace std;int a[64];int n;void deal(){int up=0,down=0,upSum=0,downSum=0;int i,j;for(i=1;i<n;){if(a[i]<a[i+1]){++up;for(j=i+1;j<=n;++j)if(a[j-1]<=a[j])++upSum;elsebreak;}if(a[i]>a[i+1]){++down;for(j=i+1;j<=n;++j)if(a[j-1]>=a[j])++downSum;elsebreak;}if(a[i]==a[i+1]){int flag=0;for(j=i+1;j<=n;++j)if(a[j-1]<a[j]){flag=1;break;}else if(a[j-1]>a[j]){flag=-1;break;}if(flag==0)break;if(flag==1){++up;for(j=i+1;j<=n;++j)if(a[j-1]<=a[j])++upSum;elsebreak;}if(flag==-1){++down;for(j=i+1;j<=n;++j)if(a[j-1]>=a[j])++downSum;elsebreak;}}i=j-1;}double f1,f2;if(upSum==0)f1=0;elsef1=upSum*1.0/up;if(downSum==0)f2=0;elsef2=downSum*1.0/down;printf("Nr values = %d: %.6lf %.6lf\n",n,f1,f2);}int main(){n=0;while(1){int x;scanf("%d",&x);if(x==0){if(n==0)break;deal();n=0;}elsea[++n]=x;}return 0;}
0 0
- poj 1492 Up and Down Sequences 模拟计数
- zoj 1338 || poj 1492 Up and Down Sequences
- UVa413 - Up and Down Sequences
- zoj 1338 Up and Down Sequences
- ZOJ 1338 Up and Down Sequences
- ZOJ 1338 Up and Down Sequences
- ZOJ 1338 Up and Down Sequences
- TOJ 1101. Up and Down Sequences
- UVa 413 - Up and Down Sequences
- 1338_Up and Down Sequences
- Codeforces 653C Bear and Up-Down 【模拟】
- volume up and down
- Percolate Up and Down
- pta Percolate Up and Down
- IndiaHacks 2016 - Online Edition (Div. 1 + Div. 2) C. Bear and Up-Down【模拟】
- Top-down and bottom-up parser
- Swapping GridView rows Up and Down
- SZU:A12 Jumping up and down
- Spring.NET学习笔记6——依赖注入(应用篇) Level 300
- 34-UITableView—团购实例
- HTTP 错误 404.8 - Not Found,请求筛选模块被配置为拒绝包含 hiddenSegment 节的 URL 中的路径
- 设计模式之工厂模式与抽象工厂模式
- 与内存对齐有关的sizeof
- poj 1492 Up and Down Sequences 模拟计数
- 自定义视图——Day02_2
- 王斌老师的博客
- hdu 2014 青年歌手大奖赛_评委会打分
- Oracle 11g R2 RAC高可用连接特性 – SCAN详解
- SharePoint 2013 开启访问请求 链接丢失
- 阅读程序写出运行结果1
- 黑马程序员-IOS-C语言基础-scanf函数
- mongodb shell问题