結果

問題 No.492 IOI数列
ユーザー 37zigen37zigen
提出日時 2017-03-11 02:56:54
言語 Java21
(openjdk 21)
結果
AC  
実行時間 136 ms / 1,000 ms
コード長 1,938 bytes
コンパイル時間 2,225 ms
コンパイル使用メモリ 76,096 KB
実行使用メモリ 56,296 KB
最終ジャッジ日時 2023-09-06 15:09:20
合計ジャッジ時間 6,276 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 136 ms
56,296 KB
testcase_01 AC 122 ms
55,860 KB
testcase_02 AC 120 ms
55,644 KB
testcase_03 AC 121 ms
55,900 KB
testcase_04 AC 119 ms
54,108 KB
testcase_05 AC 121 ms
55,916 KB
testcase_06 AC 120 ms
56,008 KB
testcase_07 AC 120 ms
55,760 KB
testcase_08 AC 120 ms
55,588 KB
testcase_09 AC 119 ms
55,992 KB
testcase_10 AC 120 ms
56,008 KB
testcase_11 AC 120 ms
55,576 KB
testcase_12 AC 129 ms
55,392 KB
testcase_13 AC 129 ms
55,420 KB
testcase_14 AC 130 ms
55,508 KB
testcase_15 AC 129 ms
55,720 KB
testcase_16 AC 129 ms
55,888 KB
testcase_17 AC 119 ms
55,772 KB
testcase_18 AC 122 ms
55,980 KB
testcase_19 AC 121 ms
56,028 KB
testcase_20 AC 118 ms
54,480 KB
testcase_21 AC 118 ms
55,832 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.Scanner;
import java.util.concurrent.SynchronousQueue;
import java.math.*;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	static long[][] mx = { { 100, 1 }, { 1, 0 } };
	static long MODULO = 1000000007;
	BigInteger MODULO2 = new BigInteger("101010101010101010101");
	static BigInteger[] arr = new BigInteger[100];

	void run() {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		System.out.println((pow(100, N) - 1 + MODULO) * (inv(99, MODULO) % MODULO) % MODULO);
		BigInteger a = new BigInteger("0");
		arr[0] = a;
		for (int i = 1; i < arr.length; ++i) {
			arr[i] = arr[i - 1].multiply(BigInteger.valueOf(100)).add(BigInteger.ONE).mod(MODULO2);
		}
		System.out.println(arr[(int) (N % 11)]);
	}

	// ax+b(mo)=V
	// x+0*mo=x
	// 0*x+1*mo=mo;
	long inv(long x, long mo) {
		x %= mo;
		long curA = 1;
		long curB = 0;
		long preA = 0;
		long preB = 1;
		long curV = x;
		long preV = mo;
		while (curV != 1) {
			long q = preV / curV;
			preA -= q * curA;
			preB -= q * curB;
			preV -= q * curV;

			long tmp = curV;
			curV = preV;
			preV = tmp;
			tmp = curA;
			curA = preA;
			preA = tmp;
			tmp = curB;
			curB = preB;
			preB = tmp;
		}
		while (curA < 0)
			curA += mo;
		return curA;
	}

	long pow(long a, long n) {
		long ret = 1;
		for (; n > 0; n >>= 1, a = (a * a) % MODULO) {
			if (n % 2 == 1) {
				ret *= a;
				ret %= MODULO;
			}
		}
		return ret;
	}

	long[][] mul(long[][] a, long[][] b) {
		if (a[0].length != b.length)
			throw new AssertionError();
		long[][] ret = new long[a.length][b[0].length];
		for (int i = 0; i < a.length; ++i) {
			for (int j = 0; j < b[0].length; ++j) {
				for (int k = 0; k < a[j].length; ++k) {
					ret[i][j] = (ret[i][j] + a[i][k] * b[k][j]) % MODULO;
				}
			}
		}
		return ret;
	}

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

}
0