fork(2) download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int x;
  8. unsigned int p, w;
  9. while (cin >> x)
  10. {
  11. cin >> p;
  12. cin >> w;
  13. if (w == 0)
  14. {
  15. cout << 1 << endl;
  16. continue;
  17. }
  18.  
  19. if(p % 10 == 1)
  20. cout << 1 << endl;
  21.  
  22. else if(p % 10 == 2 && w % 4 == 1)
  23. cout << 2 << endl;
  24. else if (p % 10 == 2 && w % 4 == 2)
  25. cout << 4 << endl;
  26. else if (p % 10 == 2 && w % 4 == 3)
  27. cout << 8 << endl;
  28. else if (p % 10 == 2 && w % 4 == 0)
  29. cout << 6 << endl;
  30.  
  31. else if (p % 10 == 3 && w % 4 == 1)
  32. cout << 3 << endl;
  33. else if (p % 10 == 3 && w % 4 == 2)
  34. cout << 9 << endl;
  35. else if (p % 10 == 3 && w % 4 == 3)
  36. cout << 7 << endl;
  37. else if (p % 10 == 3 && w % 4 == 0)
  38. cout << 1 << endl;
  39.  
  40. else if (p % 10 == 4 && w % 2 == 1)
  41. cout << 4 << endl;
  42. else if (p % 10 == 4 && w % 2 == 0)
  43. cout << 6 << endl;
  44.  
  45. else if (p % 10 == 5)
  46. cout << 5 << endl;
  47.  
  48. else if (p % 10 == 6)
  49. cout << 6 << endl;
  50.  
  51. else if (p % 10 == 7 && w % 4 == 1)
  52. cout << 7 << endl;
  53. else if (p % 10 == 7 && w % 4 == 2)
  54. cout << 9 << endl;
  55. else if (p % 10 == 7 && w % 4 == 3)
  56. cout << 3 << endl;
  57. else if (p % 10 == 7 && w % 4 == 0)
  58. cout << 1 << endl;
  59.  
  60. else if (p % 10 == 8 && w % 4 == 1)
  61. cout << 8 << endl;
  62. else if (p % 10 == 8 && w % 4 == 2)
  63. cout << 4 << endl;
  64. else if (p % 10 == 8 && w % 4 == 3)
  65. cout << 2 << endl;
  66. else if (p % 10 == 8 && w % 4 == 0)
  67. cout << 6 << endl;
  68.  
  69. else if (p % 10 == 9 && w % 2 == 1)
  70. cout << 9 << endl;
  71. else if (p % 10 == 9 && w % 2 == 0)
  72. cout << 1 << endl;
  73.  
  74. else if(p % 10 == 0)
  75. cout << 0 << endl;
  76. }
  77. return 0;
  78. }
  79.  
  80.  
Success #stdin #stdout 0s 15232KB
stdin
Standard input is empty
stdout
Standard output is empty