I - small P and small Q

Recently, I found that it is really important to observe the test samples carefully (find the pattern), make a bold guess, and try ! ! !

Link: https://www.nowcoder.com/acm/contest/115/I
Source : Niuke.com
Time limit: C/C++ 1 second, other languages ​​2 seconds
Space limit: C/C++ 32768K, other languages ​​65536K
64bit IO Format: %lldTitle
description 
Little P and Little Q are good friends, and today they play a fun game together.
They all start with a score of 1, and the winner can multiply their score by (K squared), and the loser can also multiply by K.
They had so much fun that they forgot how long they had been playing, even how much K was and how many rounds N the game was going on.
Now give the final points a and b of the two of them, ask whether there are positive integers K and N satisfying such points, and judge whether their game results are credible.
Input description: In
the first line, enter an integer T (representing the number of samples).
Next
, each group of samples in T groups has one line, and input two positive integers a,b (0<a,b<=1e9)
Output description:
Output T lines, line by
line, output the result corresponding to an example.
If the result is credible, output Yes
. Otherwise, output No.
Example 1
Input
6
2 4
75 45
8 8
16 16
247 994
1000000000 1000000
Output
Yes
Yes
Yes
No
No
Yes
Note:
K may be different each round

#include<bits/stdc++.h>
using namespace std;
intmain()
{
    int n,m,t;
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d%d",&n,&m);
        long long ans=(long long)n*m;
        float a=(float)cbrt(ans);//a=(float)pow(ans,1.0/3);
        if(a==(int)a) printf("Yes\n");
        else printf("No\n");
    }
    return 0;
}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324649208&siteId=291194637