fork download
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4.  
  5. bool is_concluded(int x, int y) {
  6. for (int i = 2; i * i <= x; ++i) {
  7. if (x % i == 0) {
  8. if (y % i != 0) return false;
  9. while (x % i == 0) x /= i;
  10. }
  11. }
  12. if (x > 1) {
  13. if (y % x != 0) return false;
  14. }
  15. return true;
  16. }
  17.  
  18. int main() {
  19. int n;
  20. cin >> n;
  21. while (n--) {
  22. int a, b;
  23. cin >> a >> b;
  24. if (is_concluded(a, b))
  25. cout << "TAK" << endl;
  26. else
  27. cout << "NIE" << endl;
  28. }
  29. return 0;
  30. }
Success #stdin #stdout 0s 5320KB
stdin
3
4 10
8 4
7 7
stdout
TAK
TAK
TAK