Code Forces 833 A The Meaningless Game(思维,数学)

时间:2020-04-21
本文章向大家介绍Code Forces 833 A The Meaningless Game(思维,数学),主要包括Code Forces 833 A The Meaningless Game(思维,数学)使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

Code Forces 833 A The Meaningless Game

题目大意

有两个人玩游戏,每轮给出一个自然数k,赢得人乘k^2,输得人乘k,给出最后两个人的分数,问两个人能否达到这个分数

不得不吐槽一下那么长的英文题面翻译完只有一句话……

solution

也很好想叭
乘积开立方判断是否为两个数的因数
如果是的话,显然不成立
否则输出Yes即可

#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#define int long long
using namespace std;

inline int read(){
    int x = 0, w = 1;
    char ch = getchar();
    for(; ch > '9' || ch < '0'; ch = getchar()) if(ch == '-') w = -1;
    for(; ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
    return x * w;
}

signed main(){
    int n = read();
    while(n--){
        int a = read(), b = read();
        int tmp = a * b;
        // int awsl = pow(tmp, (1.0 / 3)) + 0.5;
        int awsl = cbrt((double)a*(double)b);//在网上找到了这个开三次方的函数,啧啧
        if(awsl * awsl * awsl != tmp || a % awsl || b % awsl) cout << "No" << endl;
        else cout << "Yes" << endl;
    }
    return 0;
}

原文地址:https://www.cnblogs.com/rui-4825/p/12743737.html