Recent Posts
Notice
No Rules Rules
곱셈 (feat. 백준, 1629번) 본문
728x90
반응형
곱셈
https://www.acmicpc.net/problem/1629
1629번: 곱셈
첫째 줄에 A, B, C가 빈 칸을 사이에 두고 순서대로 주어진다. A, B, C는 모두 2,147,483,647 이하의 자연수이다.
www.acmicpc.net
반응형
// woohyeon.kim
// kim519620.tistory.com
#include <iostream>
using namespace std;
int A, B, C;
int my_pow(register int n, register int k) {
if (k == 0)
return 1;
register int tmp = my_pow(n, k / 2);
register int result = static_cast<int>(static_cast<long long>(1) * tmp * tmp % C);
if (k % 2)
result = static_cast<int>(static_cast<long long>(1) * result * n % C);
return result;
}
int main() {
ios::sync_with_stdio(false), cin.tie(NULL);
cin >> A >> B >> C;
cout << my_pow(A, B);
return 0;
}
// *&)*@*
728x90
반응형
'생활 > 코테' 카테고리의 다른 글
행렬 곱셈 (feat. 백준, 2740번) (0) | 2022.08.15 |
---|---|
이항 계수 3 (feat. 백준, 11401번) (0) | 2022.08.15 |
종이의 개수 (feat. 백준, 1780번) (0) | 2022.08.14 |
쿼드트리 (feat. 백준, 1992번) (0) | 2022.08.14 |
색종이 만들기 (feat. 백준, 2630번) (0) | 2022.08.13 |
Comments