結果

問題 No.492 IOI数列
ユーザー snrnsidysnrnsidy
提出日時 2021-07-15 22:29:29
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 1,239 bytes
コンパイル時間 2,049 ms
コンパイル使用メモリ 205,760 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-18 07:31:38
合計ジャッジ時間 2,995 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

vector <vector<unsigned long long int>> mul(vector <vector<unsigned long long int>> a, vector<vector<unsigned long long int>> b)
{
	vector <vector<unsigned long long int>>c(3, vector<unsigned long long int>(3,0));

	for (int i = 0; i < 3; i++)
	{
		for (int j = 0; j <3; j++)
		{
			for (int k = 0; k < 3; k++)
			{
				c[i][j] += ((a[i][k] % 1000000007) * (b[k][j] % 1000000007));
				c[i][j] %= 1000000007;
			}
		}
	}

	return c;
}


int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	long long int N;

	cin >> N;
	vector <vector <unsigned long long int>> a(3, vector<unsigned long long int>(3,0));
	vector <vector <unsigned long long int>> b(3, vector<unsigned long long int>(3,0));
	a[0][0] = 100;
	a[0][2] = 1;
	a[1][0] = 1;
	a[2][2] = 1;

	b[0][0] = 1;
	b[1][1] = 1;
	b[2][2] = 1;

	long long int n = N - 1;
	while (n > 0)
	{
		if (n & 1)
		{
			b = mul(a, b);
		}
		a = mul(a, a);
		n >>= 1;
	}
	
	long long int res = b[0][0];
	res += b[0][1];
	res += b[0][2];
	res %= 1000000007;
	cout << res << '\n';
	if (N % 11 == 0)
	{
		cout << 0 << '\n';
	}
	else
	{
		int n = N % 11;
		for (int i = 0; i < n - 1; i++)
		{
			cout << "10";
		}
		cout << "1" << '\n';
	}
	return 0;
}
0