diff --git a/src/week1/BOJ1629/BOJ1629_V1.cpp b/src/week1/BOJ1629/BOJ1629_V1.cpp new file mode 100644 index 0000000..7d4bf2b --- /dev/null +++ b/src/week1/BOJ1629/BOJ1629_V1.cpp @@ -0,0 +1,26 @@ +#include +using namespace std; +long long a,b,c; + +long long power(long long x, long long y) { + + if (y == 1) + return 1; + + long long half = power(x, y/2); + half = (half * half) % c; + + if (y % 2 == 1) + half = (half * x) % c; + + return half; + +} +int main() { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + + cin >> a >> b >> c; + + cout << power(a, b) % c << "\n"; +} \ No newline at end of file