From fd6083001499e5685b6cd5e24b1bad31f1624930 Mon Sep 17 00:00:00 2001 From: sh0723 Date: Sun, 24 May 2026 00:52:46 +0900 Subject: [PATCH] =?UTF-8?q?1629=20:=20=EA=B3=B1=EC=85=88=20solve?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/week1/BOJ1629/BOJ1629_V1.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/week1/BOJ1629/BOJ1629_V1.cpp 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