SOLUTION - Lũy thừa

Lũy thừa:

Reference C++ AC Code
#include <bits/stdc++.h>
using namespace std;
#define int long long
int ltnp(int a, int b){
    int kq = 1, d, c;
    while (b > 0) {
        c = 1; d = a;
        while (c <= b / 2) { 
            c = c * 2; d = (d * d) % 10000; 
        } b -= c; kq = (kq * d) %10000;
    } return kq;
}
main() {
    int a,b; cin >>a >> b; 
    cout << ltnp (a,b);
    return 0;
}

Bình luận (2)

Mới nhất
Tải bình luận...