結果

問題 No.722 100×100=1000
ユーザー YamaKasaYamaKasa
提出日時 2018-08-04 11:09:29
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 2,324 bytes
コンパイル時間 2,196 ms
コンパイル使用メモリ 79,684 KB
実行使用メモリ 41,564 KB
最終ジャッジ日時 2024-04-20 15:05:30
合計ジャッジ時間 6,421 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 110 ms
41,164 KB
testcase_01 AC 95 ms
40,340 KB
testcase_02 AC 106 ms
40,160 KB
testcase_03 AC 99 ms
40,024 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 106 ms
39,948 KB
testcase_08 AC 106 ms
39,948 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 106 ms
40,420 KB
testcase_12 AC 109 ms
41,076 KB
testcase_13 AC 110 ms
41,172 KB
testcase_14 AC 105 ms
40,888 KB
testcase_15 AC 97 ms
40,188 KB
testcase_16 WA -
testcase_17 AC 106 ms
40,340 KB
testcase_18 AC 106 ms
40,448 KB
testcase_19 WA -
testcase_20 AC 110 ms
40,108 KB
testcase_21 AC 105 ms
40,252 KB
testcase_22 AC 95 ms
39,984 KB
testcase_23 AC 112 ms
41,444 KB
testcase_24 WA -
testcase_25 AC 108 ms
41,088 KB
testcase_26 AC 97 ms
40,300 KB
testcase_27 AC 108 ms
40,936 KB
testcase_28 AC 105 ms
40,776 KB
testcase_29 AC 99 ms
40,216 KB
testcase_30 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String A = scan.next();
		String B = scan.next();
		scan.close();
		int cnt1 = 0;
		int cnt2 = 0;
		for(int i = 0; i < A.length(); i++) {
			if(A.charAt(i) == '0') {
				cnt1 ++;
			}
		}
		for(int i = 0; i < B.length(); i++) {
			if(B.charAt(i) == '0') {
				cnt2 ++;
			}
		}

		if(A.charAt(0) != '-' && B.charAt(0) != '-') {
			if(cnt1 == A.length() - 1 && cnt2 == B.length() - 1) {
				int t1 = Integer.parseInt(A.substring(0, 1));
				int t2 = Integer.parseInt(B.substring(0, 1));
				int ans = t1 * t2;
				System.out.print(ans);
				for(int i = 0; i < cnt1 + cnt2 - 1; i++) {
					System.out.print("0");
				}
				System.out.println();
			}else {
				long t1 = Integer.parseInt(A);
				long t2 = Integer.parseInt(B);
				long ans = t1 * t2;
				if(ans >= 0) {
					String k = Long.toString(ans);
					if(k.length() <= 8) {
						System.out.println(k);
					}else {
						System.out.println("E");
					}
				}
			}
		}else if(A.charAt(0) != '-' || B.charAt(0) != '-') {
			long t1 = Integer.parseInt(A);
			long t2 = Integer.parseInt(B);
			if(t1 < 0) {
				t1 = -t1;
			}
			if(t2 < 0) {
				t2 = -t2;
			}
			String A1 = Long.toString(t1);
			String B1 = Long.toString(t2);
			if(cnt1 == A1.length() - 1&& cnt2 == B1.length() - 1) {
				long ans = t1 * t2;
				String k = Long.toString(ans);
				k = k.substring(0, k.length() - 1);
				System.out.println("-" + k);
			}else {
				long ans = t1 * t2;
				if(ans >= 0) {
					String k = Long.toString(ans);
					if(k.length() <= 8) {
						System.out.println(k);
					}else {
						System.out.println("E");
					}
				}

			}
		}else {
			if(cnt1 == A.length() - 1&& cnt2 == B.length() - 1) {
				int t1 = Integer.parseInt(A.substring(0, 1));
				int t2 = Integer.parseInt(B.substring(0, 1));
				int ans = t1 * t2;
				System.out.print(ans);
				for(int i = 0; i < cnt1 + cnt2 - 1; i++) {
					System.out.print("0");
				}
				System.out.println();
			}else {
				long t1 = Integer.parseInt(A);
				long t2 = Integer.parseInt(B);
				long ans = t1 * t2;
				if(ans >= 0) {
					String k = Long.toString(ans);
					if(k.length() <= 8) {
						System.out.println(k);
					}else {
						System.out.println("E");
					}
				}
			}
		}
	}
}
0