Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- const int MAXN = 1000005;
- typedef long long ll;
- ll cuberoot(ll x) {
- ll l = 0, r = MAXN;
- while (l != r) {
- ll m = (l + r + 1) / 2;
- if (m * m * m > x) {
- r = m - 1;
- }
- else {
- l = m;
- }
- }
- return l;
- }
- int main()
- {
- ios_base::sync_with_stdio(false); cin.tie(0);
- int n;
- cin >> n;
- for (int i = 0; i < n; i++)
- {
- ll l, r;
- cin >> l >> r;
- ll x = cuberoot(l * r);
- if (x * x * x != l * r) {
- cout << "NO" << "\n";
- }
- else if (l % x == 0 && r % x == 0) {
- cout << "YES" << "\n";
- }
- else {
- cout << "NO" << "\n";
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement