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; }
相关推荐
xceman 2020-10-13
算法与数学之美 2020-10-07
Anscor 2020-10-05
liwg0 2020-09-08
数学爱好者 2020-08-31
thermodynamicB 2020-08-11
夕加加 2020-07-20
willowwgx 2020-07-18
kuoying 2020-07-16
Anscor 2020-07-14
starletkiss 2020-07-08
kingzone 2020-06-27
xceman 2020-06-27
算法与数学之美 2020-06-21
kuoying 2020-06-21
秒懂数学 2020-06-17