結果

問題 No.722 100×100=1000
ユーザー YamaKasaYamaKasa
提出日時 2018-08-04 11:27:19
言語 Java19
(openjdk 21)
結果
AC  
実行時間 118 ms / 2,000 ms
コード長 2,408 bytes
コンパイル時間 3,874 ms
コンパイル使用メモリ 76,080 KB
実行使用メモリ 56,552 KB
最終ジャッジ日時 2023-08-28 15:48:25
合計ジャッジ時間 6,813 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 111 ms
55,596 KB
testcase_01 AC 114 ms
55,700 KB
testcase_02 AC 112 ms
55,184 KB
testcase_03 AC 117 ms
55,328 KB
testcase_04 AC 116 ms
55,692 KB
testcase_05 AC 113 ms
55,724 KB
testcase_06 AC 113 ms
55,384 KB
testcase_07 AC 113 ms
55,548 KB
testcase_08 AC 113 ms
55,832 KB
testcase_09 AC 118 ms
55,680 KB
testcase_10 AC 118 ms
55,468 KB
testcase_11 AC 113 ms
54,192 KB
testcase_12 AC 112 ms
55,824 KB
testcase_13 AC 112 ms
55,676 KB
testcase_14 AC 113 ms
55,800 KB
testcase_15 AC 114 ms
55,580 KB
testcase_16 AC 117 ms
56,228 KB
testcase_17 AC 114 ms
55,888 KB
testcase_18 AC 113 ms
55,936 KB
testcase_19 AC 113 ms
56,552 KB
testcase_20 AC 117 ms
55,912 KB
testcase_21 AC 112 ms
55,840 KB
testcase_22 AC 114 ms
55,536 KB
testcase_23 AC 116 ms
55,784 KB
testcase_24 AC 111 ms
54,476 KB
testcase_25 AC 113 ms
56,220 KB
testcase_26 AC 115 ms
55,748 KB
testcase_27 AC 112 ms
55,728 KB
testcase_28 AC 111 ms
55,400 KB
testcase_29 AC 112 ms
55,824 KB
testcase_30 AC 111 ms
55,408 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() - 2&& cnt2 == B.length() - 2) {
				int t1 = Integer.parseInt(A.substring(1, 2));
				int t2 = Integer.parseInt(B.substring(1, 2));
				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