結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 115 ms
41,248 KB
testcase_01 AC 106 ms
40,136 KB
testcase_02 AC 112 ms
40,588 KB
testcase_03 AC 111 ms
40,228 KB
testcase_04 AC 111 ms
39,928 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 115 ms
39,916 KB
testcase_08 AC 118 ms
41,288 KB
testcase_09 AC 124 ms
41,224 KB
testcase_10 AC 116 ms
40,300 KB
testcase_11 AC 105 ms
40,332 KB
testcase_12 AC 107 ms
40,200 KB
testcase_13 AC 115 ms
40,400 KB
testcase_14 AC 118 ms
41,148 KB
testcase_15 AC 115 ms
41,224 KB
testcase_16 AC 110 ms
40,024 KB
testcase_17 AC 114 ms
40,156 KB
testcase_18 AC 117 ms
41,028 KB
testcase_19 WA -
testcase_20 AC 119 ms
40,112 KB
testcase_21 AC 112 ms
41,000 KB
testcase_22 AC 117 ms
41,044 KB
testcase_23 AC 108 ms
40,348 KB
testcase_24 WA -
testcase_25 AC 104 ms
40,208 KB
testcase_26 AC 117 ms
41,356 KB
testcase_27 AC 118 ms
41,384 KB
testcase_28 AC 106 ms
40,420 KB
testcase_29 AC 117 ms
41,416 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