結果

問題 No.428 小数から逃げる夢
ユーザー tenten
提出日時 2022-10-12 18:33:05
言語 Java
(openjdk 23)
結果
AC  
実行時間 96 ms / 1,000 ms
コード長 1,443 bytes
コンパイル時間 3,914 ms
コンパイル使用メモリ 78,948 KB
実行使用メモリ 53,320 KB
最終ジャッジ日時 2024-06-26 11:26:19
合計ジャッジ時間 13,758 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 100
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Main {
    static char[] D = "1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991".toCharArray();
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int n = sc.nextInt();
        int base = 0;
        StringBuilder sb = new StringBuilder();
        for (int i = D.length - 1; i >= 0; i--) {
            base += n * (D[i] - '0');
            sb.append(base % 10);
            base /= 10;
        }
        System.out.println(base + "." + sb.reverse());
    }
}
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 String next() throws Exception {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
    
}
0