結果

問題 No.293 4>7の世界
ユーザー fjafjafjafjafjafja
提出日時 2017-09-25 23:15:19
言語 Java21
(openjdk 21)
結果
AC  
実行時間 127 ms / 2,000 ms
コード長 624 bytes
コンパイル時間 3,242 ms
コンパイル使用メモリ 72,548 KB
実行使用メモリ 56,260 KB
最終ジャッジ日時 2023-08-28 22:23:10
合計ジャッジ時間 7,387 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 126 ms
55,988 KB
testcase_01 AC 125 ms
56,172 KB
testcase_02 AC 123 ms
55,800 KB
testcase_03 AC 125 ms
55,884 KB
testcase_04 AC 123 ms
56,128 KB
testcase_05 AC 122 ms
55,924 KB
testcase_06 AC 124 ms
56,156 KB
testcase_07 AC 124 ms
55,972 KB
testcase_08 AC 125 ms
54,352 KB
testcase_09 AC 122 ms
56,096 KB
testcase_10 AC 123 ms
55,812 KB
testcase_11 AC 124 ms
56,036 KB
testcase_12 AC 125 ms
55,984 KB
testcase_13 AC 127 ms
56,120 KB
testcase_14 AC 125 ms
55,960 KB
testcase_15 AC 125 ms
56,260 KB
testcase_16 AC 124 ms
55,780 KB
testcase_17 AC 123 ms
55,832 KB
testcase_18 AC 124 ms
55,968 KB
testcase_19 AC 124 ms
55,804 KB
testcase_20 AC 126 ms
55,996 KB
testcase_21 AC 124 ms
55,964 KB
testcase_22 AC 125 ms
56,004 KB
testcase_23 AC 124 ms
55,976 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class N293 {

	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		long a=sc.nextLong(),b=sc.nextLong();
		long aa=a,bb=b;
		long ans=-1;
		int arank=(int)Math.log10(a)+1,brank=(int)Math.log10(b)+1;
		if(arank!=brank){}
		else
		{
			for(int i=arank;i>0;i--)
			{
				long ten=(long)Math.pow(10, i-1);
				long abuf=aa/ten,bbuf=bb/ten;
				if((abuf==4&&bbuf==7)||(abuf==7&&bbuf==4))
				{ans=(abuf==4)?a:b;break;}
				if(abuf!=bbuf){break;}
				aa-=abuf*ten;bb-=bbuf*ten;
			}

		}

		if(ans==-1)
		{
			ans=(a>=b)?a:b;
		}
		System.out.println(ans);


	}

}
0