結果

問題 No.793 うし数列 2
ユーザー GrenacheGrenache
提出日時 2019-04-27 23:55:12
言語 Java21
(openjdk 21)
結果
AC  
実行時間 131 ms / 2,000 ms
コード長 880 bytes
コンパイル時間 3,281 ms
コンパイル使用メモリ 74,756 KB
実行使用メモリ 41,396 KB
最終ジャッジ日時 2024-05-07 10:49:44
合計ジャッジ時間 6,507 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 111 ms
41,020 KB
testcase_01 AC 114 ms
41,112 KB
testcase_02 AC 113 ms
41,060 KB
testcase_03 AC 103 ms
39,396 KB
testcase_04 AC 103 ms
39,908 KB
testcase_05 AC 98 ms
39,516 KB
testcase_06 AC 112 ms
41,088 KB
testcase_07 AC 112 ms
40,008 KB
testcase_08 AC 115 ms
41,384 KB
testcase_09 AC 118 ms
41,396 KB
testcase_10 AC 103 ms
39,960 KB
testcase_11 AC 111 ms
41,256 KB
testcase_12 AC 98 ms
39,752 KB
testcase_13 AC 113 ms
41,360 KB
testcase_14 AC 116 ms
41,232 KB
testcase_15 AC 114 ms
41,376 KB
testcase_16 AC 118 ms
41,296 KB
testcase_17 AC 131 ms
41,112 KB
testcase_18 AC 113 ms
41,028 KB
testcase_19 AC 115 ms
40,856 KB
testcase_20 AC 113 ms
41,368 KB
testcase_21 AC 102 ms
39,844 KB
testcase_22 AC 117 ms
41,132 KB
権限があれば一括ダウンロードができます

ソースコード

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