Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int t,a,b,osta,ostb,ostfinal,pom;
- int tab[4][4] = { {2,4,8,6}, {3,9,7,1}, {7,9,3,1}, {8,4,2,6} };
- cin>>t;
- for(int i=0;i<t;i++)
- {
- cin>>a>>b;
- osta=a%10;
- ostb=b%10;
- if(ostb==0) ostb=b%100;
- //cout<<osta<<endl<<ostb<<endl;
- if(osta==0 || osta == 1 || osta == 5 || osta == 6) ostfinal=osta;
- if(osta==4 || osta == 9) // podstawa 4 lub 9
- {
- pom=ostb%2;
- if(pom==0) ostfinal=6;
- else ostfinal=4;
- }
- if(osta == 9) // podstawa 4 lub 9
- {
- pom=ostb%2;
- if(pom==0) ostfinal=1;
- else ostfinal=9;
- }
- if(osta==2)
- {
- pom=b%4;
- if(pom==0) pom=4;
- ostfinal=tab[0][pom-1];
- }
- if(osta==3)
- {
- pom=b%4;
- // cout<<" pom "<<pom;
- if(pom==0) pom=4;
- ostfinal=tab[1][pom-1];
- }
- if(osta==7)
- {
- pom=b%4;
- if(pom==0) pom=4;
- ostfinal=tab[2][pom-1];
- }
- if(osta==8)
- {
- pom=b%4;
- if(pom==0) pom=4;
- ostfinal=tab[3][pom-1];
- }
- cout<<ostfinal<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement