Baekjoon/C++
[백준 1009번] 분산처리
Yo-mi
2023. 7. 25. 23:36
#include <iostream>
using namespace std;
int main() {
int num, a;
unsigned long long b, result;
cin >> num;
for (int i = 0; i < num; i++) {
cin >> a >> b;
result = a;
if (b == 1) {
result = result % 10;
if (result == 0)
result = 10;
}
else {
for (int j = 0; j < b - 1; j++) {
result = (result * a) % 10;
if (result == 0) {
result = 10;
break;
}
}
}
cout << result << '\n';
}
return 0;
}
문제를 해석해 보면 결국 첫째 자리 숫자가 무엇인지가 궁금한 것이다.