結果

問題 No.722 100×100=1000
ユーザー YamaKasaYamaKasa
提出日時 2018-08-04 11:16:39
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 2,408 bytes
コンパイル時間 2,060 ms
コンパイル使用メモリ 80,280 KB
実行使用メモリ 53,892 KB
最終ジャッジ日時 2024-04-20 15:05:46
合計ジャッジ時間 6,338 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 113 ms
41,380 KB
testcase_01 AC 98 ms
40,040 KB
testcase_02 AC 101 ms
40,156 KB
testcase_03 AC 105 ms
41,384 KB
testcase_04 AC 107 ms
40,340 KB
testcase_05 AC 115 ms
41,248 KB
testcase_06 AC 102 ms
40,124 KB
testcase_07 AC 98 ms
40,992 KB
testcase_08 AC 102 ms
40,156 KB
testcase_09 AC 107 ms
40,144 KB
testcase_10 AC 118 ms
40,020 KB
testcase_11 AC 117 ms
41,060 KB
testcase_12 AC 112 ms
39,752 KB
testcase_13 AC 111 ms
40,412 KB
testcase_14 AC 110 ms
40,048 KB
testcase_15 AC 112 ms
41,180 KB
testcase_16 AC 115 ms
41,428 KB
testcase_17 AC 105 ms
41,540 KB
testcase_18 AC 113 ms
40,380 KB
testcase_19 WA -
testcase_20 AC 115 ms
41,156 KB
testcase_21 AC 113 ms
40,084 KB
testcase_22 AC 104 ms
41,372 KB
testcase_23 AC 112 ms
40,800 KB
testcase_24 AC 102 ms
41,176 KB
testcase_25 AC 120 ms
41,024 KB
testcase_26 AC 104 ms
41,080 KB
testcase_27 AC 97 ms
40,932 KB
testcase_28 AC 103 ms
40,132 KB
testcase_29 AC 101 ms
39,916 KB
testcase_30 AC 113 ms
41,208 KB
権限があれば一括ダウンロードができます

ソースコード

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 >= 2 && cnt2 >= 2 && 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 >= 2 && cnt2 >= 2 && 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 >= 2 && cnt2 >= 2 && 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