結果

問題 No.557 点対称
ユーザー uafr_csuafr_cs
提出日時 2017-11-01 17:28:25
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 861 bytes
コンパイル時間 2,204 ms
コンパイル使用メモリ 77,552 KB
実行使用メモリ 41,652 KB
最終ジャッジ日時 2024-05-02 04:11:39
合計ジャッジ時間 7,429 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 143 ms
41,152 KB
testcase_01 RE -
testcase_02 AC 137 ms
41,068 KB
testcase_03 RE -
testcase_04 RE -
testcase_05 AC 133 ms
41,040 KB
testcase_06 AC 132 ms
41,060 KB
testcase_07 RE -
testcase_08 AC 136 ms
41,164 KB
testcase_09 AC 133 ms
41,080 KB
testcase_10 RE -
testcase_11 AC 134 ms
41,044 KB
testcase_12 AC 137 ms
40,932 KB
testcase_13 AC 134 ms
41,332 KB
testcase_14 AC 132 ms
41,264 KB
testcase_15 AC 134 ms
41,384 KB
testcase_16 RE -
testcase_17 AC 133 ms
41,452 KB
testcase_18 AC 138 ms
41,132 KB
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 AC 133 ms
40,968 KB
testcase_23 RE -
testcase_24 RE -
testcase_25 AC 134 ms
41,016 KB
testcase_26 AC 134 ms
41,216 KB
testcase_27 AC 135 ms
40,920 KB
testcase_28 AC 135 ms
40,884 KB
testcase_29 AC 134 ms
41,040 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 1l; }
		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 int N = sc.nextInt();
		
		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