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. Redis具体解释与常见问题解决方式

    Redis简单介绍 redis是一个key-value存储系统.和Memcached类似,它支持存储的value类型相对很多其它.包含string(字符串).list(链表).set(集合).zset ...

  2. 【Python】【Web.py】python调用html【问题:echart图标调用html上未显示】

    code调用123.html和echarts.min.js文件 code.py import web import execjs urls = ( '/hello', 'hello', ) app = ...

  3. myeclipse连接并运行sql文件

    1:在工程目录上右键>new >SQL File  ,写入sql 2:在sql文件上面右键>execute sql files 3:选择数据库类型,并点击create创建一个连接: ...

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

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

  5. VS2013密钥(所有版本)

    Visual Studio Ultimate 2013 KEY(密钥):BWG7X-J98B3-W34RT-33B3R-JVYW9 Visual Studio Premium 2013 KEY(密钥) ...

  6. jmeter 逻辑控制器Logic Controller详解

    Jmeter之逻辑控制器(Logic Controller) 前言: 1. Jmeter官网对逻辑控制器的解释是:“Logic Controllers determine the order in w ...

  7. iOS 网易彩票-2框架搭建-代码重构

    在上一篇中,我们基本已经把整个框架都搭建出来了,下面进行代码重构一下. 思路: 导航按钮,按下时,会变灰,那是系统自带了,通过自定义UIButton,实现按下按钮立即切换效果. MJTabBarCon ...

  8. Javascript-闰年javascript的判断

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  9. centos安装samba

    yum -y install samba samba-client samba-swat /etc/init.d/smb start chkconfig --level 35 smb on cp -p ...

  10. 020-安装centos6.5后的生命历程

    01.配置网络.修改了ifcfg-eth0文件内容. 1)ifcfg-eth0原来的内容如下: 2)ifcfg-eth0配置后的内容如下:   3)然后重启网络服务: 4)测试网络是否可通: 5)查看 ...