結果

問題 No.492 IOI数列
ユーザー fiordfiord
提出日時 2017-03-11 01:03:46
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 1,056 bytes
コンパイル時間 440 ms
コンパイル使用メモリ 68,376 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-06 14:59:31
合計ジャッジ時間 1,279 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
/*
	ai=100a(i-1)+1	->	ai+(1/99)=100(a(i-1)+1/99)
	ai=-1/99+100/99*(100)^(i-1)
	  ={(100)^i-1}/99

	1e9+7は(100)^n(mod m)を算出して1を引き、99の逆元をかければOK
	a11は	n(mod 11)		an(mod a11)
			0				0
			1				1
			2				101
			3				10101
			4				1010101
			5				101010101
			6				10101010101
			7				1010101010101
			8				101010101010101
			9				10101010101010101
			10				1010101010101010101
*/
typedef long long ll;
ll mod = 1000000007;
ll solve1(ll n) {
	//(100)^n(mod m)
	ll ret = 1;
	ll multi = 100;
	while (n) {
		if (n & 1)	ret = (ret*multi) % mod;
		n >>= 1;
		multi = (multi*multi) % mod;
	}
	//-1
	ret = (ret + mod - 1) % mod;
	//99の逆元=99^(mod-2)
	multi = 99;
	n = mod - 2;
	while (n) {
		if (n & 1)	ret = (ret*multi) % mod;
		n >>= 1;
		multi = (multi*multi) % mod;
	}
	return ret;
}

int main() {
	ll n;	cin >> n;
	cout << solve1(n) << endl;
	n %= 11;
	ll a = 0;
	for (int i = 0; i < n; i++)	a = a * 100 + 1;
	cout << a << endl;
	return 0;
}
0