結果

問題 No.557 点対称
ユーザー uafr_csuafr_cs
提出日時 2017-11-01 17:29:14
言語 Java21
(openjdk 21)
結果
AC  
実行時間 125 ms / 2,000 ms
コード長 862 bytes
コンパイル時間 3,428 ms
コンパイル使用メモリ 73,408 KB
実行使用メモリ 40,260 KB
最終ジャッジ日時 2023-08-14 16:06:32
合計ジャッジ時間 6,999 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 118 ms
39,764 KB
testcase_01 AC 123 ms
39,248 KB
testcase_02 AC 115 ms
39,604 KB
testcase_03 AC 116 ms
39,680 KB
testcase_04 AC 114 ms
39,108 KB
testcase_05 AC 114 ms
39,240 KB
testcase_06 AC 114 ms
39,464 KB
testcase_07 AC 116 ms
39,148 KB
testcase_08 AC 118 ms
39,228 KB
testcase_09 AC 115 ms
39,300 KB
testcase_10 AC 117 ms
39,112 KB
testcase_11 AC 119 ms
39,768 KB
testcase_12 AC 118 ms
39,320 KB
testcase_13 AC 117 ms
39,224 KB
testcase_14 AC 116 ms
39,204 KB
testcase_15 AC 117 ms
39,980 KB
testcase_16 AC 115 ms
40,260 KB
testcase_17 AC 119 ms
40,028 KB
testcase_18 AC 122 ms
39,780 KB
testcase_19 AC 119 ms
40,028 KB
testcase_20 AC 120 ms
39,100 KB
testcase_21 AC 118 ms
39,496 KB
testcase_22 AC 116 ms
39,036 KB
testcase_23 AC 121 ms
39,764 KB
testcase_24 AC 125 ms
39,808 KB
testcase_25 AC 121 ms
39,772 KB
testcase_26 AC 121 ms
39,040 KB
testcase_27 AC 118 ms
39,456 KB
testcase_28 AC 119 ms
39,460 KB
testcase_29 AC 118 ms
39,224 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.LinkedList;
import java.util.Scanner;

public class Main {
	
	public static long MOD = 1000000007;
	
	public static long mod_pow(long a, long x){
		if(x == 0){ return 1; }
		else if(x == 1){ return a; }
		else if(x % 2 == 1){ return (mod_pow(a, x - 1) * a) % MOD; }
		else{ 
			final long t = mod_pow(a, x / 2);
			return (t * t) % MOD;
		}
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		final long N = sc.nextLong();
		
		if(N == 1){
			System.out.println(2);
		}else if(N == 2){
			System.out.println(4);
		}else if(N % 2 == 1){
			final long run = (N - 3) / 2;
			final long x = mod_pow(5, run);
			
			System.out.println((3 * x * 4) % MOD);
		}else{
			final long run = (N - 4) / 2;
			final long x = mod_pow(5, run);
			
			System.out.println((5 * x * 4) % MOD);
		}
	}
}
0