C. The Meaningless Game

题意:

  两个人刚刚开始游戏的时候的分数, 都是一分, 然后随机一个人的分数扩大k倍,另一个扩大k的平方倍, 问给你一组最后得分,问能不能通过游戏得到这样一组得分。(谁扩大k倍, 谁扩大k的平方倍,是可以自由选择的, k的值只要是自然数就行了)。 
思路:

   对输入的两个数a, b。求(a*b) 的1/3次方, 如果不能得到,就是不能得的输出“No”。否则在看开方得到的数,能不能同时被a和b整除, 如果可以就输出“Yes”,否则就是“No”。

  本题因为AB卡题了很久,没读懂题,GG所以没怎么写C,早上补一下

用pow函数求 1/3 次方   round是四舍五入

#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + ;
const int maxn = + ;
const int INF = 0x3f3f3f3f;
typedef long long ll;
int n; void solve (ll a ,ll b)
{
ll c = round( pow(a*b,1.0/) );
// printf("%d\n",c);
if (a%c || b%c || c*c*c != a*b)
printf("No\n");
else
printf("Yes\n");
}
int main()
{
scanf("%d",&n);
for(int i=;i < n;i++){
ll a,b;
scanf("%lld %lld",&a,&b);
// printf("%lld %lld\n",a,b);
solve(a,b);
}
return ;
}

用pow函数写

二分的话  左边界是1,右边界是 max(a*b) ^(1/3) 大概做多就是 1e6 再多加2卡一下

#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + ;
const int maxn = + ;
const int INF = 0x3f3f3f3f;
typedef long long ll;
int n; int main()
{
scanf("%d",&n);
while (n--)
{
ll a,b;
scanf("%lld %lld",&a,&b);
ll le=,ri= (int)1e6+;
//printf("%lld %lld\n",le,ri);
ll ans = ;
while (le <= ri)
{
ll mid = (le+ri)/;
if(mid * mid * mid >= a*b)
ans = mid,ri=mid-;
else
le = mid+;
}
if(ans*ans*ans == a*b && a%ans ==&& b%ans==)
puts("Yes");
else
puts("No"); }
return ;
}

二分写法

第一次codeforces写出来两题  虽然还是掉分了 主要还是读题的锅...我的渣渣英语啊

Codeforces Round #426 (Div. 2) C. The Meaningless Game的更多相关文章

  1. Codeforces Round #426 (Div. 1) A.The Meaningless Game (二分+数学)

    题目链接: http://codeforces.com/problemset/problem/833/A 题意: 给你 \(a\) 和 \(b\),两个人初始化为 \(1\).两个人其中一方乘以 \( ...

  2. 【筛法求素数】Codeforces Round #426 (Div. 1) A. The Meaningless Game

    先筛出来1000以内的素数. 枚举x^(1/3) 和 y^(1/3)以内的素因子,这样除完以后对于x和y剩下的因子,小的那个的平方必须等于大的. 然后判断每个素因数的次数之和是否为3的倍数,并且小的那 ...

  3. CodeForces 834C - The Meaningless Game | Codeforces Round #426 (Div. 2)

    /* CodeForces 834C - The Meaningless Game [ 分析,数学 ] | Codeforces Round #426 (Div. 2) 题意: 一对数字 a,b 能不 ...

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

    [Link]:http://codeforces.com/contest/834/problem/C [Description] 有一个两人游戏游戏; 游戏包括多轮,每一轮都有一个数字k,赢的人把自己 ...

  5. Codeforces Round #426 (Div. 2)【A.枚举,B.思维,C,二分+数学】

    A. The Useless Toy time limit per test:1 second memory limit per test:256 megabytes input:standard i ...

  6. Codeforces Round #426 (Div. 2)

    http://codeforces.com/contest/834 A. The Useless Toy 题意: <,>,^,v这4个箭头符号,每一个都可以通过其他及其本身逆时针或者顺时针 ...

  7. Codeforces Round #426 (Div. 2)A B C题+赛后小结

    最近比赛有点多,可是好像每场比赛都是被虐,单纯磨砺心态的作用.最近讲的内容也有点多,即便是点到为止很浅显的版块,刷了专题之后的状态还是~"咦,能做,可是并没有把握能A啊".每场网络 ...

  8. Codeforces Round #426 (Div. 2) A,B,C

    A. The Useless Toy 题目链接:http://codeforces.com/contest/834/problem/A 思路: 水题 实现代码: #include<bits/st ...

  9. Codeforces Round #426 (Div. 2)A题&&B题&&C题

    A. The Useless Toy:http://codeforces.com/contest/834/problem/A 题目意思:给你两个字符,还有一个n,问你旋转n次以后从字符a变成b,是顺时 ...

随机推荐

  1. hbuilder 打包app简易教程

    1. 新建app 2. 新建弹窗面板中选择MUi登录模版 ps:在弹出的窗口,填入应用名称,根据需求选择项目位置,以及模板内容. 3. 检验app效果 菜单栏 -> 运行 -> 手机运行 ...

  2. MySQL字符集的一个坑

    MySQL字符集的一个坑 http://imysql.com/2013/10/29/misunderstand-about-charset-handshake.shtml MySQL字符集的一个坑 1 ...

  3. 空类指针为什么可以调用类的成员函数 以及 A(){}和A();

    1. 代码及问题 #include <iostream> using namespace std; class A { public: A() {} //A *p = new A()时:此 ...

  4. Oil Deposits(poj 1526 DFS入门题)

    http://poj.org/problem?id=1562                                                                       ...

  5. 如何快速获取ListView的打气筒对象

    简单的方式有三种: @Override public View getView(int position, View convertView, ViewGroup parent) { View vie ...

  6. notification 是同步的

    所有notification的观察者执行之后,post notification的函数才会往下执行.

  7. selenium WebDriver处理文件下载

    下载文件WebDriver 允许我们设置默认的文件下载路径.也就是说文件会自动下载并且存在设置的那个目录中.下面以FireFox 为例执行文件的下载. package com.mypro.jase; ...

  8. html05

    1.js中的对象-内置对象-外部对象-自定义对象 2.常见的内置对象有哪些?-String对象-Number对象-Boolean对象-Array对象-Math对象-Date对象-RegExp正则对象- ...

  9. liunx anacoda 安装pyltp

    anacoda 默认的gcc是4.7需要更新 https://anaconda.org/nlesc/gcc 更新之后再安装即可. 报错: /usr/lib64/libstdc++.so.6: vers ...

  10. 改变 select下拉框 样式

    select{ outline: none; text-indent: 10px; height: 45px; line-height: 45px; width: 100%; border:1px s ...