結果

問題 No.333 門松列を数え上げ
ユーザー TakaTaka
提出日時 2016-04-03 23:15:07
言語 Java21
(openjdk 21)
結果
AC  
実行時間 135 ms / 2,000 ms
コード長 468 bytes
コンパイル時間 2,233 ms
コンパイル使用メモリ 74,144 KB
実行使用メモリ 54,364 KB
最終ジャッジ日時 2024-04-10 11:05:36
合計ジャッジ時間 4,180 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 132 ms
54,264 KB
testcase_01 AC 130 ms
54,260 KB
testcase_02 AC 133 ms
54,144 KB
testcase_03 AC 133 ms
54,160 KB
testcase_04 AC 134 ms
54,272 KB
testcase_05 AC 135 ms
54,352 KB
testcase_06 AC 133 ms
53,992 KB
testcase_07 AC 135 ms
54,364 KB
testcase_08 AC 135 ms
54,256 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
		
        Scanner sc = new Scanner(System.in);
		
       	int a = sc.nextInt();
		
        int b = sc.nextInt();
		
		int c=0;
		
		if(a<b){
			if(a==1 && b==2)	c=0;
			else if(a+1==b)	c=a-1;
			else	c=(b-a-1)+(a-1);
		}else if(a>b){
			if(a==2000000000)	c=a-b-1;
			else if(a-1==b)	c=2000000000-a;
			else c=(2000000000-a)+(a-b-1);
		}
        System.out.println(c);
    }
}
0