結果

問題 No.1844 Divisors Sum Sum
ユーザー 杨娵隅杨娵隅
提出日時 2022-02-19 03:23:04
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 688 ms / 3,000 ms
コード長 1,214 bytes
コンパイル時間 2,038 ms
コンパイル使用メモリ 200,744 KB
実行使用メモリ 4,716 KB
最終ジャッジ日時 2023-09-11 20:29:01
合計ジャッジ時間 13,176 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 688 ms
4,632 KB
testcase_01 AC 686 ms
4,620 KB
testcase_02 AC 688 ms
4,716 KB
testcase_03 AC 688 ms
4,616 KB
testcase_04 AC 688 ms
4,676 KB
testcase_05 AC 685 ms
4,576 KB
testcase_06 AC 686 ms
4,580 KB
testcase_07 AC 685 ms
4,560 KB
testcase_08 AC 686 ms
4,624 KB
testcase_09 AC 685 ms
4,560 KB
testcase_10 AC 628 ms
4,436 KB
testcase_11 AC 133 ms
4,380 KB
testcase_12 AC 476 ms
4,376 KB
testcase_13 AC 68 ms
4,380 KB
testcase_14 AC 225 ms
4,376 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 1 ms
4,384 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 1 ms
4,384 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 1 ms
4,380 KB
testcase_29 AC 2 ms
4,388 KB
testcase_30 AC 1 ms
4,380 KB
testcase_31 AC 2 ms
4,376 KB
testcase_32 AC 2 ms
4,380 KB
testcase_33 AC 2 ms
4,380 KB
testcase_34 AC 2 ms
4,380 KB
testcase_35 AC 1 ms
4,384 KB
testcase_36 AC 2 ms
4,380 KB
testcase_37 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
array<array<long long, 3>, 3> matmul(array<array<long long, 3>, 3> A, array<array<long long, 3>, 3> B){
	array<array<long long, 3>, 3> ans = {array<long long, 3>{0, 0, 0}, array<long long, 3>{0, 0, 0}, array<long long, 3>{0, 0, 0}};
  for (int i = 0; i < 3; i++){
		for (int j = 0; j < 3; j++){
			for (int k = 0; k < 3; k++){
				ans[i][k] += A[i][j] * B[j][k];
				ans[i][k] %= MOD;
			}
		}
	}
	return ans;
}
array<array<long long, 3>, 3> matexp(array<array<long long, 3>, 3> A, long long b){
	array<array<long long, 3>, 3> ans = {array<long long, 3>{1, 0, 0}, array<long long, 3>{0, 1, 0}, array<long long, 3>{0, 0, 1}};
	while (b > 0){
		if (b % 2 == 1){
			ans = matmul(ans, A);
		}
		A = matmul(A, A);
		b /= 2;
	}
	return ans;
}
int main(){
  int L;
  cin >> L;
  vector<int> P(L), e(L);
  for (int i = 0; i < L; i++){
    cin >> P[i] >> e[i];
  }
  long long ans = 1;
  for (int i = 0; i < L; i++){
    array<array<long long, 3>, 3> A = {array<long long, 3>{P[i], 1, 1}, array<long long, 3>{0, 1, 1}, array<long long, 3>{0, 0, 1}};
    A = matexp(A, e[i] + 1);
    ans *= A[0][2];
    ans %= MOD;
  }
  cout << ans << endl;
}
0