当前位置: 代码迷 >> 综合 >> HDOJ 1330 Deck
  详细解决方案

HDOJ 1330 Deck

热度:68   发布时间:2023-10-21 19:33:44.0

HDACM 1330

习惯性打表,一次性过

import java.util.Scanner;public class Main{public static void main(String[] args) {double len[] = new double[100000];double sum = 0;for (int i = 1; i < len.length; i++) {sum += 1.0/(i*2);len[i]=sum;}Scanner sc = new Scanner(System.in);boolean isFirst = true;while (sc.hasNext()) {if (isFirst) {System.out.println("# Cards Overhang");isFirst = false;}int n = sc.nextInt();System.out.printf("%5d %.3f",n,len[n]);System.out.println();}}
}