結果

問題 No.557 点対称
ユーザー uafr_csuafr_cs
提出日時 2017-11-01 17:28:25
言語 Java19
(openjdk 21)
結果
RE  
実行時間 -
コード長 861 bytes
コンパイル時間 4,476 ms
コンパイル使用メモリ 73,664 KB
実行使用メモリ 56,500 KB
最終ジャッジ日時 2023-08-14 16:05:17
合計ジャッジ時間 9,410 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 116 ms
38,988 KB
testcase_01 RE -
testcase_02 AC 110 ms
39,004 KB
testcase_03 RE -
testcase_04 RE -
testcase_05 AC 123 ms
39,324 KB
testcase_06 AC 115 ms
39,148 KB
testcase_07 RE -
testcase_08 AC 123 ms
39,200 KB
testcase_09 AC 118 ms
39,084 KB
testcase_10 RE -
testcase_11 AC 117 ms
39,248 KB
testcase_12 AC 118 ms
39,620 KB
testcase_13 AC 117 ms
39,660 KB
testcase_14 AC 118 ms
39,628 KB
testcase_15 AC 118 ms
39,532 KB
testcase_16 RE -
testcase_17 AC 120 ms
39,216 KB
testcase_18 AC 115 ms
39,432 KB
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 AC 124 ms
39,856 KB
testcase_23 RE -
testcase_24 RE -
testcase_25 AC 117 ms
39,360 KB
testcase_26 AC 117 ms
39,660 KB
testcase_27 AC 115 ms
39,152 KB
testcase_28 AC 116 ms
39,576 KB
testcase_29 AC 113 ms
39,464 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