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

题意
检测两个数是否可以表示成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_back
typedef 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::endl
const 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
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值