結果

問題 No.492 IOI数列
ユーザー mbanmban
提出日時 2017-04-13 21:01:05
言語 Java21
(openjdk 21)
結果
AC  
実行時間 131 ms / 1,000 ms
コード長 1,113 bytes
コンパイル時間 3,352 ms
コンパイル使用メモリ 73,908 KB
実行使用メモリ 56,164 KB
最終ジャッジ日時 2023-09-25 16:29:58
合計ジャッジ時間 7,209 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
55,768 KB
testcase_01 AC 124 ms
55,908 KB
testcase_02 AC 123 ms
56,072 KB
testcase_03 AC 128 ms
55,932 KB
testcase_04 AC 127 ms
55,936 KB
testcase_05 AC 127 ms
55,784 KB
testcase_06 AC 126 ms
55,792 KB
testcase_07 AC 126 ms
55,952 KB
testcase_08 AC 125 ms
55,812 KB
testcase_09 AC 126 ms
55,760 KB
testcase_10 AC 124 ms
55,944 KB
testcase_11 AC 126 ms
55,968 KB
testcase_12 AC 126 ms
56,100 KB
testcase_13 AC 129 ms
56,164 KB
testcase_14 AC 128 ms
55,976 KB
testcase_15 AC 131 ms
55,780 KB
testcase_16 AC 128 ms
55,868 KB
testcase_17 AC 125 ms
55,760 KB
testcase_18 AC 125 ms
55,700 KB
testcase_19 AC 125 ms
55,744 KB
testcase_20 AC 125 ms
55,916 KB
testcase_21 AC 124 ms
55,956 KB
権限があれば一括ダウンロードができます

ソースコード

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;
			b/=2;
		}
		return result;
	}
}
0