zoukankan      html  css  js  c++  java
  • POJ1877 Flooded! 赛前水一题

      题目链接:http://poj.org/problem?id=1877

      赛前水一题,希望明天的邀请赛能取得好的成绩!

     1 //STATUS:C++_AC_110MS_200KB
     2 #include <functional>
     3 #include <algorithm>
     4 #include <iostream>
     5 #include <fstream>
     6 #include <sstream>
     7 #include <iomanip>
     8 #include <numeric>
     9 #include <cstring>
    10 #include <cassert>
    11 #include <cstdio>
    12 #include <string>
    13 #include <vector>
    14 #include <bitset>
    15 #include <queue>
    16 #include <stack>
    17 #include <cmath>
    18 #include <ctime>
    19 #include <list>
    20 #include <set>
    21 #include <map>
    22 using namespace std;
    23 //define
    24 #define pii pair<int,int>
    25 #define mem(a,b) memset(a,b,sizeof(a))
    26 #define lson l,mid,rt<<1
    27 #define rson mid+1,r,rt<<1|1
    28 #define PI acos(-1.0)
    29 //typedef
    30 typedef long long LL;
    31 typedef unsigned long long ULL;
    32 //const
    33 const int N=1010;
    34 const int INF=0x3f3f3f3f;
    35 const int MOD=100000,STA=8000010;
    36 const LL LNF=1LL<<60;
    37 const double EPS=1e-8;
    38 const double OO=1e15;
    39 const int dx[4]={-1,0,1,0};
    40 const int dy[4]={0,1,0,-1};
    41 //Daily Use ...
    42 inline int sign(double x){return (x>EPS)-(x<-EPS);}
    43 template<class T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
    44 template<class T> T lcm(T a,T b){return a/gcd(a,b)*b;}
    45 template<class T> inline T Min(T a,T b){return a<b?a:b;}
    46 template<class T> inline T Max(T a,T b){return a>b?a:b;}
    47 template<class T> inline T Min(T a,T b,T c){return min(min(a, b),c);}
    48 template<class T> inline T Max(T a,T b,T c){return max(max(a, b),c);}
    49 template<class T> inline T Min(T a,T b,T c,T d){return min(min(a, b),min(c,d));}
    50 template<class T> inline T Max(T a,T b,T c,T d){return max(max(a, b),max(c,d));}
    51 //End
    52 
    53 double ma[N];
    54 double v;
    55 int n,m;
    56 
    57 
    58 int main()
    59 {
    60   //  freopen("in.txt","r",stdin);
    61   //  freopen("out.txt","w",stdout);
    62     int i,j,cnt,k=1;
    63     double h,vt,t[N];
    64     while(~scanf("%d%d",&n,&m) && (n || m) )
    65     {
    66         n*=m;
    67         for(i=0;i<n;i++)
    68                 scanf("%lf",&ma[i]);
    69         scanf("%lf",&v);
    70 
    71         sort(ma,ma+n);
    72         for(i=0;i<n;i++)t[i]=ma[i+1]-ma[i];
    73         for(i=0;i<n-1;i++){
    74             vt=(i+1)*100*t[i];
    75             if(vt<=v)v-=vt;
    76             else break;
    77         }
    78         cnt=i+1;
    79         h=ma[i]+v/(cnt*100);
    80 
    81         printf("Region %d\n",k++);
    82         printf("Water level is %.2lf meters.\n",h);
    83         printf("%.2lf percent of the region is under water.\n\n",(double)cnt*100/n);
    84     }
    85     return 0;
    86 }
  • 相关阅读:
    org.apache.zookeeper.ClientCnxn
    Oracle数据库 number 长度与 Short Integer Long BigDecimal 对应关系
    Spring中 PROPAGATION_REQUIRED 解释
    java的static final和final的区别
    本地调试有数据,发布到服务器没更新的问题
    java的double类型如何精确到一位小数?
    consul配置参数大全、详解、总结
    深入对比TOML,JSON和YAML
    基于Jenkins,docker实现自动化部署(持续交互)【转】
    让Linux任务在后台可靠运行的几种方法
  • 原文地址:https://www.cnblogs.com/zhsl/p/3072247.html
Copyright © 2011-2022 走看看