You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
# include <bits/stdc++.h>
using namespace std ;
int main ( ) {
int a , b ;
cin > > a > > b ;
//个位数
a = a % 10 ;
if ( b = = 0 ) {
cout < < 1 < < endl ;
return 0 ;
}
// 0 1 5 6多少次方都是自己
if ( a = = 0 | | a = = 1 | | a = = 5 | | a = = 6 ) {
cout < < a < < endl ;
return 0 ;
}
//如果是2, 那么按2 4 8 6循环
if ( a = = 2 ) {
b = b % 4 ;
if ( b = = 1 ) {
cout < < 2 < < endl ;
return 0 ;
}
if ( b = = 2 ) {
cout < < 4 < < endl ;
return 0 ;
}
if ( b = = 3 ) {
cout < < 8 < < endl ;
return 0 ;
}
if ( b = = 0 ) {
cout < < 6 < < endl ;
return 0 ;
}
}
//如果是3
if ( a = = 3 ) {
b = b % 4 ;
if ( b = = 1 ) {
cout < < 3 < < endl ;
return 0 ;
}
if ( b = = 2 ) {
cout < < 9 < < endl ;
return 0 ;
}
if ( b = = 3 ) {
cout < < 7 < < endl ;
return 0 ;
}
if ( b = = 0 ) {
cout < < 1 < < endl ;
return 0 ;
}
}
//如果是4
if ( a = = 4 ) {
b = b % 2 ;
if ( b = = 1 ) {
cout < < 4 < < endl ;
return 0 ;
}
if ( b = = 0 ) {
cout < < 6 < < endl ;
return 0 ;
}
}
//如果是7
if ( a = = 7 ) {
b = b % 4 ;
if ( b = = 1 ) {
cout < < 7 < < endl ;
return 0 ;
}
if ( b = = 2 ) {
cout < < 9 < < endl ;
return 0 ;
}
if ( b = = 3 ) {
cout < < 3 < < endl ;
return 0 ;
}
if ( b = = 0 ) {
cout < < 1 < < endl ;
return 0 ;
}
}
//如果是8
if ( a = = 8 ) {
b = b % 4 ;
if ( b = = 1 ) {
cout < < 8 < < endl ;
return 0 ;
}
if ( b = = 2 ) {
cout < < 4 < < endl ;
return 0 ;
}
if ( b = = 3 ) {
cout < < 2 < < endl ;
return 0 ;
}
if ( b = = 0 ) {
cout < < 6 < < endl ;
return 0 ;
}
}
//如果是9
if ( a = = 9 ) {
b = b % 2 ;
if ( b = = 1 ) {
cout < < 9 < < endl ;
return 0 ;
}
if ( b = = 0 ) {
cout < < 1 < < endl ;
return 0 ;
}
}
return 0 ;
}