結果

問題 No.1235 ζ関数
ユーザー tentententen
提出日時 2023-04-14 18:55:48
言語 Java21
(openjdk 21)
結果
AC  
実行時間 428 ms / 2,000 ms
コード長 1,635 bytes
コンパイル時間 2,332 ms
コンパイル使用メモリ 91,428 KB
実行使用メモリ 51,440 KB
最終ジャッジ日時 2024-04-18 16:43:12
合計ジャッジ時間 9,847 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 409 ms
51,360 KB
testcase_01 AC 281 ms
51,440 KB
testcase_02 AC 274 ms
51,248 KB
testcase_03 AC 282 ms
51,368 KB
testcase_04 AC 428 ms
51,372 KB
testcase_05 AC 287 ms
51,368 KB
testcase_06 AC 274 ms
51,236 KB
testcase_07 AC 281 ms
51,184 KB
testcase_08 AC 281 ms
51,424 KB
testcase_09 AC 275 ms
51,184 KB
testcase_10 AC 277 ms
51,308 KB
testcase_11 AC 271 ms
51,308 KB
testcase_12 AC 275 ms
51,200 KB
testcase_13 AC 270 ms
51,256 KB
testcase_14 AC 276 ms
51,236 KB
testcase_15 AC 274 ms
51,304 KB
testcase_16 AC 412 ms
51,372 KB
testcase_17 AC 274 ms
51,240 KB
testcase_18 AC 275 ms
51,384 KB
testcase_19 AC 279 ms
51,264 KB
testcase_20 AC 273 ms
51,388 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 = 10000000; i >= 1; i--) {
            ans += 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