MCPcopy Create free account
hub / github.com/E869120/math-algorithm-book / Power

Function Power

codes/cpp/Code_4_07_1.cpp:21–31  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19}
20
21Matrix Power(Matrix A, long long n) { // A �� n ���Ԃ��֐�
22 Matrix P = A, Q; bool flag = false;
23 for (int i = 0; i < 60; i++) {
24 if ((n & (1LL << i)) != 0LL) {
25 if (flag == false) { Q = P; flag = true; }
26 else { Q = Multiplication(Q, P); }
27 }
28 P = Multiplication(P, P);
29 }
30 return Q;
31}
32
33int main() {
34 // ���� �� �ݏ�̌v�Z�iN �� 2 �ȏ�łȂ���ΐ��������삵�Ȃ��̂Œ��Ӂj

Callers 1

mainFunction · 0.70

Calls 1

MultiplicationFunction · 0.70

Tested by

no test coverage detected