// Copyright © 2021 ์์ฃผํ. All rights reserved.
//
// https://www.acmicpc.net/problem/1009
// BOJ1009 ๋ถ์ฐ์ฒ๋ฆฌ
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int N; cin >> N;
while (N--) {
int a, b; cin >> a >> b;
if (b % 4 == 0)b = 4; //๋ชจ๋ ์ ๊ณฑ๋ค์ด 4์ ์ฃผ๊ธฐ๋ฅผ ๊ฐ์ง.
else b %= 4;
long long final = pow(a, b);
if (final % 10 == 0) cout << 10<<"\n";
else cout << final % 10 << "\n";
}
}
'Algorithm ๐ง๐ปโ๐ป > ๋ฐฑ์ค(BOJ)' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[๋ฐฑ์ค,c++] 1015๋ฒ - ์์ด ์ ๋ ฌ (0) | 2021.10.16 |
---|---|
[๋ฐฑ์ค,c++] 1012๋ฒ - ์ ๊ธฐ๋ ๋ฐฐ์ถ (0) | 2021.10.16 |
[๋ฐฑ์ค,c++] 1010๋ฒ - ๋ค๋ฆฌ ๋๊ธฐ (0) | 2021.10.16 |
[๋ฐฑ์ค,c++] 1005๋ฒ - ACM Craft (0) | 2021.10.16 |
[๋ฐฑ์ค,c++] 1003๋ฒ - ํผ๋ณด๋์น ํจ์ (0) | 2021.10.16 |
[๋ฐฑ์ค,c++] 10026๋ฒ - ์ ๋ก์์ฝ (0) | 2021.10.16 |
๋๊ธ