結果

問題 No.492 IOI数列
ユーザー SSRSSSRS
提出日時 2020-11-25 07:37:08
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 1,150 bytes
コンパイル時間 788 ms
コンパイル使用メモリ 76,556 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-10-01 01:40:37
合計ジャッジ時間 1,716 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
using namespace std;
const long long MOD = 1000000007;
vector<vector<long long>> matrix_multiplication(vector<vector<long long>> A, vector<vector<long long>> B){
	int N = A.size();
	vector<vector<long long>> C(N, vector<long long>(N, 0));
	for (int i = 0; i < N; i++){
		for (int j = 0; j < N; j++){
			for (int k = 0; k < N; k++){
				C[i][k] += A[i][j] * B[j][k];
				C[i][k] %= MOD;
			}
		}
	}
	return C;
}
vector<vector<long long>> matrix_exponentiation(vector<vector<long long>> A, long long x){
	int N = A.size();
	vector<vector<long long>> ans(N, vector<long long>(N, 0));
	for (int i = 0; i < N; i++){
		ans[i][i] = 1;
	}
	while (x > 0){
		if (x % 2 == 1){
			ans = matrix_multiplication(ans, A);
		}
		A = matrix_multiplication(A, A);
		x /= 2;
	}
	return ans;
}
int main(){
	long long N;
	cin >> N;
	vector<vector<long long>> M = {{100, 0}, {1, 1}};
	M = matrix_exponentiation(M, N);
	long long ans1 = M[1][0];
	cout << ans1 << endl;
	long long ans2 = 0;
	if (N % 11 != 0){
		ans2 = 1;
		for (int i = 0; i < N % 11 - 1; i++){
			ans2 = ans2 * 100 + 1;
		}
	}
	cout << ans2 << endl;
}
0