Advertisement
Guest User

Untitled

a guest
Jun 27th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5.  
  6. int main()
  7. {
  8. int t,a,b,osta,ostb,ostfinal,pom;
  9. int tab[4][4] = { {2,4,8,6}, {3,9,7,1}, {7,9,3,1}, {8,4,2,6} };
  10. cin>>t;
  11. for(int i=0;i<t;i++)
  12. {
  13. cin>>a>>b;
  14. osta=a%10;
  15. ostb=b%10;
  16. if(ostb==0) ostb=b%100;
  17.  
  18.  
  19. //cout<<osta<<endl<<ostb<<endl;
  20. if(osta==0 || osta == 1 || osta == 5 || osta == 6) ostfinal=osta;
  21. if(osta==4 || osta == 9) // podstawa 4 lub 9
  22. {
  23. pom=ostb%2;
  24. if(pom==0) ostfinal=6;
  25. else ostfinal=4;
  26. }
  27. if(osta == 9) // podstawa 4 lub 9
  28. {
  29. pom=ostb%2;
  30. if(pom==0) ostfinal=1;
  31. else ostfinal=9;
  32. }
  33. if(osta==2)
  34. {
  35. pom=b%4;
  36.  
  37. if(pom==0) pom=4;
  38. ostfinal=tab[0][pom-1];
  39.  
  40. }
  41. if(osta==3)
  42. {
  43. pom=b%4;
  44. // cout<<" pom "<<pom;
  45. if(pom==0) pom=4;
  46.  
  47. ostfinal=tab[1][pom-1];
  48.  
  49. }
  50. if(osta==7)
  51. {
  52. pom=b%4;
  53. if(pom==0) pom=4;
  54. ostfinal=tab[2][pom-1];
  55.  
  56. }
  57. if(osta==8)
  58. {
  59. pom=b%4;
  60. if(pom==0) pom=4;
  61. ostfinal=tab[3][pom-1];
  62.  
  63. }
  64.  
  65. cout<<ostfinal<<endl;
  66.  
  67. }
  68. return 0;
  69.  
  70.  
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement