結果

問題 No.722 100×100=1000
ユーザー matsuyoshi30matsuyoshi30
提出日時 2018-09-21 00:12:13
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 984 bytes
コンパイル時間 2,200 ms
コンパイル使用メモリ 77,692 KB
実行使用メモリ 41,964 KB
最終ジャッジ日時 2024-04-20 15:30:13
合計ジャッジ時間 7,465 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 133 ms
41,116 KB
testcase_01 AC 138 ms
41,448 KB
testcase_02 AC 137 ms
41,200 KB
testcase_03 AC 139 ms
41,964 KB
testcase_04 AC 135 ms
41,284 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 132 ms
41,072 KB
testcase_08 AC 135 ms
41,724 KB
testcase_09 AC 133 ms
41,180 KB
testcase_10 AC 136 ms
41,576 KB
testcase_11 AC 136 ms
41,388 KB
testcase_12 AC 134 ms
41,460 KB
testcase_13 AC 133 ms
41,292 KB
testcase_14 AC 132 ms
41,312 KB
testcase_15 AC 133 ms
41,032 KB
testcase_16 AC 136 ms
41,364 KB
testcase_17 AC 132 ms
41,244 KB
testcase_18 AC 133 ms
41,224 KB
testcase_19 AC 121 ms
40,132 KB
testcase_20 AC 143 ms
41,584 KB
testcase_21 WA -
testcase_22 AC 121 ms
40,212 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 135 ms
41,428 KB
testcase_26 AC 126 ms
40,888 KB
testcase_27 AC 132 ms
41,524 KB
testcase_28 AC 130 ms
41,268 KB
testcase_29 AC 123 ms
40,004 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 && (A / ta >= 1 || A / ta <= 9)) ||
           (B % tb != 0 && (B / tb >= 1 || B / tb <= 9))) { // 電卓
            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