結果

問題 No.1235 ζ関数
ユーザー tentententen
提出日時 2022-08-04 16:32:45
言語 Java21
(openjdk 21)
結果
AC  
実行時間 96 ms / 2,000 ms
コード長 1,077 bytes
コンパイル時間 5,792 ms
コンパイル使用メモリ 71,488 KB
実行使用メモリ 50,476 KB
最終ジャッジ日時 2023-10-12 14:18:53
合計ジャッジ時間 7,318 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 95 ms
50,080 KB
testcase_01 AC 78 ms
50,352 KB
testcase_02 AC 79 ms
50,292 KB
testcase_03 AC 79 ms
50,296 KB
testcase_04 AC 96 ms
50,396 KB
testcase_05 AC 78 ms
50,040 KB
testcase_06 AC 78 ms
50,472 KB
testcase_07 AC 79 ms
50,212 KB
testcase_08 AC 79 ms
49,968 KB
testcase_09 AC 79 ms
50,216 KB
testcase_10 AC 79 ms
50,400 KB
testcase_11 AC 79 ms
50,164 KB
testcase_12 AC 79 ms
50,036 KB
testcase_13 AC 79 ms
48,284 KB
testcase_14 AC 79 ms
50,144 KB
testcase_15 AC 79 ms
50,204 KB
testcase_16 AC 96 ms
50,180 KB
testcase_17 AC 79 ms
50,280 KB
testcase_18 AC 80 ms
50,364 KB
testcase_19 AC 79 ms
50,476 KB
testcase_20 AC 80 ms
50,276 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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 Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    
    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 String next() throws Exception {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
}
0