結果

問題 No.722 100×100=1000
ユーザー matsuyoshi30matsuyoshi30
提出日時 2018-09-21 00:10:11
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 905 bytes
コンパイル時間 1,985 ms
コンパイル使用メモリ 74,568 KB
実行使用メモリ 54,528 KB
最終ジャッジ日時 2024-04-20 15:29:45
合計ジャッジ時間 6,775 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
54,296 KB
testcase_01 AC 125 ms
54,176 KB
testcase_02 AC 125 ms
54,292 KB
testcase_03 AC 125 ms
53,812 KB
testcase_04 AC 124 ms
54,368 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 130 ms
54,276 KB
testcase_08 AC 126 ms
54,160 KB
testcase_09 AC 127 ms
54,096 KB
testcase_10 AC 127 ms
54,044 KB
testcase_11 AC 113 ms
52,944 KB
testcase_12 AC 125 ms
54,128 KB
testcase_13 AC 124 ms
54,072 KB
testcase_14 AC 127 ms
53,876 KB
testcase_15 AC 107 ms
53,032 KB
testcase_16 AC 114 ms
53,200 KB
testcase_17 AC 122 ms
54,080 KB
testcase_18 AC 123 ms
54,372 KB
testcase_19 AC 125 ms
54,528 KB
testcase_20 AC 119 ms
53,880 KB
testcase_21 WA -
testcase_22 AC 130 ms
54,192 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 124 ms
54,152 KB
testcase_26 AC 125 ms
54,380 KB
testcase_27 AC 129 ms
54,360 KB
testcase_28 AC 126 ms
54,056 KB
testcase_29 AC 126 ms
54,168 KB
testcase_30 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        long A = in.nextLong();
        long B = in.nextLong();

        int alen = String.valueOf(A).length();
        int blen = String.valueOf(B).length();
        if(A < 0) alen--;
        if(B < 0) blen--;

        long ta = pow(alen);
        long tb = pow(blen);

        long ans = 0;
        if(A % ta != 0 || B % tb != 0) { // 電卓
            ans = A * B;
            if(ans > 99999999 || ans < -99999999)
                System.out.println("E");
            else
                System.out.println(ans);
        } else { // 暗算
            ans = A * B;
            System.out.println(ans / 10);
        }

    }

    public static int pow(int times) {
        int x = 1;
        for(int i=1; i<times; i++) {
            x *= 10;
        }
        return x;
    }
}
0