結果
問題 |
No.557 点対称
|
ユーザー |
![]() |
提出日時 | 2017-11-01 17:29:14 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 160 ms / 2,000 ms |
コード長 | 862 bytes |
コンパイル時間 | 2,516 ms |
コンパイル使用メモリ | 76,448 KB |
実行使用メモリ | 41,380 KB |
最終ジャッジ日時 | 2024-11-22 14:37:10 |
合計ジャッジ時間 | 7,827 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 30 |
ソースコード
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); } } }