結果

問題 No.793 うし数列 2
コンテスト
ユーザー Grenache
提出日時 2019-04-27 23:55:12
言語 Java
(openjdk 23)
結果
AC  
実行時間 137 ms / 2,000 ms
コード長 880 bytes
コンパイル時間 3,566 ms
コンパイル使用メモリ 74,680 KB
実行使用メモリ 41,600 KB
最終ジャッジ日時 2024-11-30 02:42:38
合計ジャッジ時間 7,397 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.Scanner;


public class Main_yukicoder793_1 {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		final int MOD = 1_000_000_007;

		long n = sc.nextLong();

		long ans = (4 * modPow(10, n, MOD) - 1) % MOD * modPow(3, MOD - 2, MOD) % MOD;
		
		pr.println(ans);
	}

	static long modPow(long a, long n, int MOD) {
		long loop = n;
		long ret = 1;
		long x = a % MOD;
		while (loop > 0) {
			if (loop % 2 == 1) {
				ret = ret * x % MOD;
			}
			x = x * x % MOD;
			loop /= 2;
		}

		return ret;
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);
			
		solve();
			
		pr.close();
		sc.close();
	}

	static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	}
}
0