結果

問題 No.219 巨大数の概算
ユーザー tentententen
提出日時 2023-04-21 13:15:55
言語 Java21
(openjdk 21)
結果
AC  
実行時間 221 ms / 1,500 ms
コード長 2,640 bytes
コンパイル時間 2,808 ms
コンパイル使用メモリ 85,552 KB
実行使用メモリ 44,420 KB
最終ジャッジ日時 2024-04-24 02:17:55
合計ジャッジ時間 16,278 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 202 ms
44,236 KB
testcase_01 AC 208 ms
44,088 KB
testcase_02 AC 206 ms
44,412 KB
testcase_03 AC 194 ms
43,964 KB
testcase_04 AC 201 ms
43,944 KB
testcase_05 AC 54 ms
37,236 KB
testcase_06 AC 120 ms
41,404 KB
testcase_07 AC 53 ms
37,048 KB
testcase_08 AC 114 ms
41,472 KB
testcase_09 AC 54 ms
37,044 KB
testcase_10 AC 204 ms
44,100 KB
testcase_11 AC 205 ms
44,256 KB
testcase_12 AC 210 ms
44,092 KB
testcase_13 AC 209 ms
44,180 KB
testcase_14 AC 207 ms
44,096 KB
testcase_15 AC 205 ms
44,244 KB
testcase_16 AC 199 ms
44,280 KB
testcase_17 AC 210 ms
44,164 KB
testcase_18 AC 207 ms
44,160 KB
testcase_19 AC 207 ms
44,156 KB
testcase_20 AC 204 ms
44,420 KB
testcase_21 AC 209 ms
44,304 KB
testcase_22 AC 203 ms
44,228 KB
testcase_23 AC 202 ms
44,028 KB
testcase_24 AC 213 ms
44,048 KB
testcase_25 AC 219 ms
44,100 KB
testcase_26 AC 193 ms
44,320 KB
testcase_27 AC 207 ms
44,276 KB
testcase_28 AC 209 ms
44,120 KB
testcase_29 AC 210 ms
44,028 KB
testcase_30 AC 213 ms
44,028 KB
testcase_31 AC 206 ms
43,784 KB
testcase_32 AC 204 ms
44,088 KB
testcase_33 AC 211 ms
44,040 KB
testcase_34 AC 209 ms
44,284 KB
testcase_35 AC 204 ms
44,192 KB
testcase_36 AC 211 ms
44,132 KB
testcase_37 AC 211 ms
44,012 KB
testcase_38 AC 213 ms
44,172 KB
testcase_39 AC 208 ms
44,300 KB
testcase_40 AC 209 ms
44,100 KB
testcase_41 AC 211 ms
43,936 KB
testcase_42 AC 217 ms
44,192 KB
testcase_43 AC 211 ms
43,936 KB
testcase_44 AC 214 ms
43,912 KB
testcase_45 AC 210 ms
43,996 KB
testcase_46 AC 221 ms
44,196 KB
testcase_47 AC 216 ms
44,220 KB
testcase_48 AC 213 ms
44,240 KB
testcase_49 AC 207 ms
44,056 KB
testcase_50 AC 208 ms
44,156 KB
testcase_51 AC 52 ms
37,296 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();
        StringBuilder sb = new StringBuilder();
        while (n-- > 0) {
            sb.append(new Num(sc.nextInt(), 0).pow(sc.nextInt())).append("\n");
        }
        System.out.print(sb);
    }
    
    static class Num {
        double value;
        long base;
        
        public Num(double value, long base) {
            this.value = value;
            this.base = base;
            normalize();
        }
        
        private void normalize() {
            while (value >= 10) {
                value /= 10;
                base++;
            }
        }
        
        public Num multiply(Num x) {
            return new Num(value * x.value, base + x.base);
        }
        
        public Num pow(long p) {
            if (p == 0) {
                return new Num(1, 0);
            } else if (p % 2 == 0) {
                return multiply(this).pow(p / 2);
            } else {
                return pow(p - 1).multiply(this);
            }
        }
        
        public String toString() {
            int ans = (int)(value * 10);
            return new StringBuilder().append(ans /10).append(" ").append(ans % 10).append(" ").append(base).toString();
        }
    }
}
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