#include using namespace std;

bool isPowerOfThree(int n) { if (n <= 0) { return false; } while (n % 3 == 0) { n /= 3; } return n == 1; }

int main() { int x, y; cin >> x >> y;

if (isPowerOfThree(x + y) && (x == 0 || y == 0 || isPowerOfThree(abs(x - y)))) {
    cout << "Possible" << endl;
} else {
    cout << "Impossible" << endl;
}

return 0;

}

C++ 算法题:判断点是否可达 (静态数组)

原文地址: https://www.cveoy.top/t/topic/qxej 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录