結果

問題 No.1235 ζ関数
ユーザー tentententen
提出日時 2023-08-02 11:59:38
言語 Java21
(openjdk 21)
結果
AC  
実行時間 110 ms / 2,000 ms
コード長 1,638 bytes
コンパイル時間 2,576 ms
コンパイル使用メモリ 89,640 KB
実行使用メモリ 51,688 KB
最終ジャッジ日時 2024-04-20 11:52:04
合計ジャッジ時間 5,701 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 105 ms
51,580 KB
testcase_01 AC 89 ms
51,336 KB
testcase_02 AC 89 ms
51,444 KB
testcase_03 AC 96 ms
51,332 KB
testcase_04 AC 107 ms
51,556 KB
testcase_05 AC 91 ms
51,572 KB
testcase_06 AC 91 ms
51,676 KB
testcase_07 AC 92 ms
51,432 KB
testcase_08 AC 88 ms
51,304 KB
testcase_09 AC 91 ms
51,332 KB
testcase_10 AC 91 ms
51,348 KB
testcase_11 AC 88 ms
51,236 KB
testcase_12 AC 94 ms
51,344 KB
testcase_13 AC 91 ms
51,516 KB
testcase_14 AC 90 ms
51,240 KB
testcase_15 AC 95 ms
51,172 KB
testcase_16 AC 110 ms
51,688 KB
testcase_17 AC 95 ms
51,400 KB
testcase_18 AC 93 ms
51,308 KB
testcase_19 AC 88 ms
51,456 KB
testcase_20 AC 88 ms
51,524 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int n = sc.nextInt();
        double ans = 0;
        for (int i = 1000000; i >= 1; i--) {
            ans += 1 / Math.pow(i, n);
        }
        System.out.println(new java.math.BigDecimal(ans).toPlainString());
    }
} 
class Utilities {
    static String arrayToLineString(Object[] arr) {
        return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n"));
    }
    
    static String arrayToLineString(int[] arr) {
        return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new));
    }
}
class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    StringBuilder sb = new StringBuilder();
    
    public Scanner() throws Exception {
        
    }
    
    public int nextInt() throws Exception {
        return Integer.parseInt(next());
    }
    
    public long nextLong() throws Exception {
        return Long.parseLong(next());
    }
    
    public double nextDouble() throws Exception {
        return Double.parseDouble(next());
    }
    
    public int[] nextIntArray() throws Exception {
        return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
    }
    
    public String next() throws Exception {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
    
}
0