結果

問題 No.492 IOI数列
ユーザー mbanmban
提出日時 2017-04-13 20:50:38
言語 Java19
(openjdk 21)
結果
TLE  
実行時間 -
コード長 1,104 bytes
コンパイル時間 7,029 ms
コンパイル使用メモリ 72,748 KB
実行使用メモリ 56,392 KB
最終ジャッジ日時 2023-09-25 16:29:14
合計ジャッジ時間 11,154 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
56,392 KB
testcase_01 TLE -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Program {
	public static void main(String[] args) {
		new Magatro().solve();
	}
}

class Magatro {
	private long n;
	private int MOD = 1000000007;
	private long[] anser = new long[] { 0l, 1l, 101l, 10101l, 1010101l, 101010101l, 10101010101l, 1010101010101l,
			101010101010101l, 10101010101010101l, 1010101010101010101l };

	private void scan() {
		Scanner scanner = new Scanner(System.in);
		n = scanner.nextLong();
	}

	public void solve() {
		scan();
		System.out.println(function(n, MOD));
		System.out.println(anser[(int) (n % 11)]);
	}

	private long function(long i, long mod) {
		if (i == 0) {
			return 0;
		}
		if (i == 1) {
			return 1;
		}
		if (i % 2 == 1) {
			long res = function(i - 1, mod) * 100 + 1;
			res %= mod;
			return res;
		} else {
			long res = function(i / 2, mod);
			res *= pow(100, i / 2, mod) + 1;
			res %= mod;
			return res;
		}
	}

	private long pow(long a, long b, long mod) {
		long result = 1;
		while (b > 0) {
			if (b % 2 == 1) {
				result *= a;
				result %= mod;
			}
			a *= a;
			a %= mod;
		}
		return result;
	}
}
0