/** * 多项式求和,注意输出格式 * Created by YangYuan on 2017/12/8. */ public class Problem2011 { public static void main(String[] args) { DecimalFormat df = new DecimalFormat("0.00"); Scanner scanner = new Scanner(System.in); int m = scanner.nextInt(); for (int i = 0; i < m; i++) { int x = scanner.nextInt(); double sum = 0; for (int j = 1; j <= x; j++) { if (j % 2 != 0) sum += 1F / j; else sum -= 1F / j; } System.out.println(df.format(sum)); } } }