結果

問題 No.1844 Divisors Sum Sum
ユーザー SSRSSSRS
提出日時 2022-02-18 21:41:28
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 685 ms / 3,000 ms
コード長 1,214 bytes
コンパイル時間 1,973 ms
コンパイル使用メモリ 201,416 KB
実行使用メモリ 4,664 KB
最終ジャッジ日時 2023-09-11 18:46:14
合計ジャッジ時間 13,048 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 685 ms
4,628 KB
testcase_01 AC 681 ms
4,532 KB
testcase_02 AC 684 ms
4,524 KB
testcase_03 AC 684 ms
4,648 KB
testcase_04 AC 678 ms
4,532 KB
testcase_05 AC 680 ms
4,584 KB
testcase_06 AC 681 ms
4,564 KB
testcase_07 AC 672 ms
4,548 KB
testcase_08 AC 676 ms
4,568 KB
testcase_09 AC 684 ms
4,664 KB
testcase_10 AC 617 ms
4,508 KB
testcase_11 AC 132 ms
4,376 KB
testcase_12 AC 468 ms
4,376 KB
testcase_13 AC 67 ms
4,376 KB
testcase_14 AC 224 ms
4,376 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 2 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 2 ms
4,376 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 1 ms
4,380 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,376 KB
testcase_29 AC 1 ms
4,380 KB
testcase_30 AC 1 ms
4,380 KB
testcase_31 AC 1 ms
4,376 KB
testcase_32 AC 2 ms
4,376 KB
testcase_33 AC 1 ms
4,376 KB
testcase_34 AC 2 ms
4,380 KB
testcase_35 AC 1 ms
4,376 KB
testcase_36 AC 1 ms
4,380 KB
testcase_37 AC 1 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