zoukankan      html  css  js  c++  java
  • poj 3299 java

    今天尝试一下poj平台 略有点忐忑 不知道自己能不能搞定。

    上网查了一下poj题目推荐,所以从poj 3299题开始练手。

    后来发现试了好几次都不成功,弄得我好郁闷,所以往1000这个sample里看看是什么出错,发现公共类public class 后面不应该写 “Humidex”而是要写"Main"。

    初心者的才会犯的尴尬事情。

    其次是自己编写的会造成 Presentation Error , 是因为输出结果格式不正确,后来略微调整一下就ok了。

    记住一篇文章,是《 POJ推荐50题以及ACM训练方案》 ,稍后转载,毕竟是前人经验,就跟着试试。

    其次呢,是一个网址,《JAVA解北大ACM POJ源码》,http://www.java3z.com/cwbwebhome/article/article17/POJ3.html

    可以多多参考。

    接下来是看了例题之后自己试着敲出的3299,试运行成功。

     1 import java.io.BufferedInputStream;
     2 import java.util.Scanner;
     3 
     4 
     5 public class Main{
     6     public static void main(String args[]){
     7         
     8         double e = 2.718281828;
     9         String alpha;
    10         
    11         Scanner cin = new Scanner(new BufferedInputStream(System.in));
    12         
    13         
    14         while(cin.hasNext()){
    15             
    16             double t=102,d=102,h=102;
    17             
    18             for(int i =0; i<2;i++){
    19                 alpha = cin.next();
    20                 
    21                 if(alpha.equals("H")){
    22                     h=cin.nextDouble();
    23                 }else if(alpha.equals("D")){
    24                     d=cin.nextDouble();
    25                 }else if (alpha.equals("T")) {
    26                     t=cin.nextDouble();
    27                 }else if (alpha.equals("E")) {
    28                     System.exit(0);
    29                     
    30                 }
    31             }
    32             
    33             double e2 = 6.11*Math.pow(e, 5417.7530 * ((1/273.16) - (1/(d+273.16))));
    34             
    35             if(h==102){
    36                 h=t+0.5555*(e2-10.0);
    37                 System.out.print("T ");   
    38                 System.out.printf("%.1f", t);   
    39                 System.out.print(" D ");   
    40                 System.out.printf("%.1f", d);   
    41                 System.out.print(" H ");   
    42                 System.out.printf("%.1f", h);   
    43                 System.out.println(); 
    44             }
    45             if(t==102){
    46                 t=h-0.5555*(e2-10.0);
    47                 System.out.print("T ");   
    48                 System.out.printf("%.1f", t);   
    49                 System.out.print(" D ");   
    50                 System.out.printf("%.1f", d);   
    51                 System.out.print(" H ");   
    52                 System.out.printf("%.1f", h);   
    53                 System.out.println();
    54             }
    55             if(d==102){
    56                 e2=(h-t)/0.5555+10.0;
    57                 d=1/((1/273.16)-Math.log(e2/6.11)/5417.7530)-273.16;
    58                 d=(double)Math.round(d*10)/10;
    59                 System.out.print("T ");   
    60                 System.out.printf("%.1f", t);   
    61                 System.out.print(" D ");   
    62                 System.out.printf("%.1f", d);   
    63                 System.out.print(" H ");   
    64                 System.out.printf("%.1f", h);   
    65                 System.out.println();
    66                 
    67             }
    68 
    69             
    70         }
    71     
    72     }
    73 }
    View Code

    好了,多多练习,加油,小星星~

  • 相关阅读:
    linux异步信号handle浅析
    数据库的基本操作增删改查
    POJ1789Truck History最小生成树两种做法(Kruskal+Prim)模板题
    POJ1113Wall求凸包周长
    POJ3565AntsKM变形
    HDU2150Pipe判断线段是否相交
    POJ1815Friendship最大流最小割点+拆点+枚举
    HDU3081 Marriage Match II 最大匹配+并查集+匈牙利算法
    POJ3348Cows求凸包面积
    HDU3277Marriage Match III并查集+二分+最大流
  • 原文地址:https://www.cnblogs.com/sasaxu/p/3240994.html
Copyright © 2011-2022 走看看