Codeforces Round #426 (Div. 2) C The Meaningless Game

来源:互联网 发布:淘宝卖aj的正品店 编辑:程序博客网 时间:2024/06/07 10:30

题意
检测两个数是否可以表示成a=k1^2*k2+k3*k4^2 b = k1*k2^2*k3^2*k4
即一个是平方,一个就是原本的.
我推了一些简单的必要条件,进行堆叠,勉强过了,但是具体还不知道,留待后考吧.

/* Farewell. */#include <iostream>#include <vector>#include <cstdio>#include <string.h>#include <algorithm>#include <queue>#include <map>#include <string>#include <cmath>#include <bitset>#include <iomanip>#include <set>using namespace std;#define FFF freopen("in.txt","r",stdin);freopen("out.txt","w",stdout);#define gcd __gcd#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1#define MP make_pair#define MT make_tuple#define PB push_backtypedef long long  LL;typedef unsigned long long ULL;typedef pair<int,int > pii;typedef pair<LL,LL> pll;typedef pair<double,double > pdd;typedef pair<double,int > pdi;const int INF = 0x7fffffff;const LL INFF = 0x7f7f7f7fffffffff;const int MOD = 1e9+7;#define debug(x) std::cerr << #x << " = " << (x) << std::endlconst int MAXM = 5e3+17;const int MAXN = 1e6+17;LL cub[MAXN];int main(int argc, char const *argv[]){        #ifdef GoodbyeMonkeyKing        freopen("in.txt","r",stdin);freopen("out.txt","w",stdout);    #endif    for (int i = 0; i < MAXN; ++i)    {        cub[i] = 1LL*(i+1)*(i+1)*(i+1);    }    int t;    cin>>t;    while(t--)    {        LL a,b;        scanf("%lld%lld",&a,&b);        LL temp = a*b;        //debug(temp);        //debug(cub[lower_bound(cub, cub+MAXN, temp)-cub]);        if(cub[lower_bound(cub, cub+MAXN, temp)-cub]!=temp)        {            puts("NO");            continue;        }        LL oa = a,ob = b;        if(a==b)        {            if(a==1)            {                puts("YES");                continue;            }            if(cub[lower_bound(cub, cub+1002, a)-cub]==a)                puts("YES");            else                puts("NO");            continue;        }        LL gd = gcd(a,b);        a/=gd;        b/=gd;        if(gd%(a*b)==0)        {            puts("YES");        }        else puts("NO");    }    return 0;}
阅读全文
0 0