ACM之路——POJ刷题(Java,持续更新中)

来源:互联网 发布:mac版腾讯视频设置在哪 编辑:程序博客网 时间:2024/05/20 19:45

<span style="font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255);">我是使用Java来刷题的</span>

先拿一些水题练练手了

poj1003,poj1004,poj1005,poj1207,poj3299,poj2159,poj2739,poj1083,poj2262,poj3006,poj2255,poj3094

1.POJ1003

import java.util.Scanner;/** * Created by mxc2011 on 2015/1/25. */public class POJ1003 {    public static void main(String[] args){        Scanner in = new Scanner(System.in);        while(true) {            double m = in.nextDouble();            double sum = 0.0;            int i = 1;            if (m < 0.00001) {                System.exit(0);            }            if (m <= 0.5) {                System.out.println("1 card(s)");            } else {                while (sum < m) {                    i++;                    sum = sum + 1.0 / i;                }                System.out.println((i - 1) + " card(s)");            }        }    }}

2.POJ1004

import java.util.Scanner;/** * Created by mxc2011 on 2015/1/25. */public class POJ1004 {    public static void main(String[] args){        Scanner in = new Scanner(System.in);        double sum = 0.0;        for (int i = 0; i < 12; i++){            sum = sum + in.nextDouble();        }        System.out.printf("$%.2f", sum/12);    }}

3.POJ1207

0 1