結果

問題 No.557 点対称
ユーザー uafr_csuafr_cs
提出日時 2017-11-01 17:29:14
言語 Java21
(openjdk 21)
結果
AC  
実行時間 145 ms / 2,000 ms
コード長 862 bytes
コンパイル時間 2,608 ms
コンパイル使用メモリ 77,436 KB
実行使用メモリ 41,500 KB
最終ジャッジ日時 2024-05-02 04:12:49
合計ジャッジ時間 8,051 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 128 ms
41,028 KB
testcase_01 AC 138 ms
41,372 KB
testcase_02 AC 136 ms
41,500 KB
testcase_03 AC 137 ms
41,072 KB
testcase_04 AC 145 ms
41,204 KB
testcase_05 AC 141 ms
41,240 KB
testcase_06 AC 143 ms
41,352 KB
testcase_07 AC 134 ms
41,204 KB
testcase_08 AC 137 ms
41,260 KB
testcase_09 AC 139 ms
41,368 KB
testcase_10 AC 140 ms
41,192 KB
testcase_11 AC 139 ms
41,364 KB
testcase_12 AC 139 ms
41,392 KB
testcase_13 AC 140 ms
41,148 KB
testcase_14 AC 142 ms
41,060 KB
testcase_15 AC 136 ms
41,396 KB
testcase_16 AC 140 ms
41,472 KB
testcase_17 AC 144 ms
41,152 KB
testcase_18 AC 142 ms
41,160 KB
testcase_19 AC 139 ms
41,280 KB
testcase_20 AC 138 ms
41,320 KB
testcase_21 AC 141 ms
41,424 KB
testcase_22 AC 137 ms
41,216 KB
testcase_23 AC 137 ms
41,412 KB
testcase_24 AC 138 ms
41,220 KB
testcase_25 AC 138 ms
41,268 KB
testcase_26 AC 139 ms
41,176 KB
testcase_27 AC 138 ms
41,244 KB
testcase_28 AC 139 ms
41,332 KB
testcase_29 AC 138 ms
41,460 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