fork(2) download
  1. #include <iostream>
  2. #include <stdio.h>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. unsigned D = 0;
  8. cin >> D;
  9. unsigned int a[D];
  10. unsigned int b[D];
  11.  
  12. for (unsigned char i=1; i<=D; i++)
  13. {
  14. cin >> a[i] >> b[i];
  15. }
  16.  
  17. for (unsigned char i=1; i<=D; i++)
  18. {
  19. int c=1;
  20. if (b[i]!=0)
  21. {
  22. c=b[i]%4;
  23.  
  24. switch(c)
  25. {
  26. case 0: cout << (a[i]*a[i]*a[i]*a[i])%10 << endl; break;
  27. case 1: cout << (a[i])%10 << endl; break;
  28. case 2: cout << (a[i]*a[i])%10 << endl; break;
  29. case 3: cout << (a[i]*a[i]*a[i])%10 << endl; break;
  30. }
  31. }
  32. else
  33. {
  34. cout << 1 << endl;
  35. }
  36. }
  37.  
  38. getchar();
  39. return 0;
  40. }
  41.  
Success #stdin #stdout 0s 3412KB
stdin
Standard input is empty
stdout
Standard output is empty