1. 833A The Meaningless Game

大意: 初始分数为$1$, 每轮选一个$k$, 赢的人乘$k^2$, 输的人乘$k$, 给定最终分数, 求判断是否成立.

判断一下$a\cdot b$是否是立方数, 以及能否被那个立方的因子整除即可. cbrt竟然有误差, 特判了一下, 好坑 

#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <bitset>
#include <functional>
#include <random>
#define REP(i,a,n) for(int i=a;i<=n;++i)
#define PER(i,a,n) for(int i=n;i>=a;--i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(a) ({REP(__i,1,n) cout<<a[__i]<<',';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head


int main() {
    int n;
    scanf("%d", &n);
    while (n--) {
        int a, b;
        scanf("%d%d", &a, &b);
        ll x = (ll)a*b, t = cbrt(x);
        while (t*t*t>x) --t;
        while (t*t*t<x) ++t;
        puts(t*t*t==x&&a%t==0&&b%t==0?"Yes":"No");
    }
}
View Code

相关文章:

  • 2021-05-28
  • 2021-07-03
  • 2021-07-04
  • 2022-01-08
  • 2022-01-24
  • 2021-07-29
  • 2021-10-10
猜你喜欢
  • 2021-11-29
  • 2021-12-08
  • 2021-09-20
  • 2022-01-16
  • 2021-09-03
相关资源
相似解决方案