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. kubernetes实战(十四):k8s持久化部署gitlab集成openLDAP登录

    1.基本概念 使用k8s安装gitlab-ce,采用GlusterFS实现持久化(注意PG使用的是NFS存储,使用动态存储重启postgresql的pod后无法成功启动pg,待解决),并集成了open ...

  2. sass和css的calc运算

    1.sass不识别不同单位之间的计算,而calc则没问题. width: #{1rem - 2px}; /*出错*/ width: calc(1rem - 2px); 通常情况定制css样式,我不需要 ...

  3. Chart控件的使用实例

    ChartTest.aspx: <%@ Page Language="C#" AutoEventWireup="true" CodeBehind=&quo ...

  4. WordPress 3.8 后台仪表盘将重新设计

    WordPress 3.8 的后台仪表盘界面将会重新设计 概况(RightNow) -> 改为网站内容(SiteContent) 快速发布(QuickPress) -> 改为快速草稿(Qu ...

  5. edgeR使用学习【转载】

    转自:http://yangl.net/2016/09/27/edger_usage/ 1.Quick start 2. 利用edgeR分析RNA-seq鉴别差异表达基因: #加载软件包 librar ...

  6. postman返回参数的截取

    同事在使用postman接口测试的时候,遇到这么一个问题,在一个参数里面,返回了一个类似数组的参数,如下: 然后现在需要把数组里面的两个参数分别保存到环境变量里面: 个人的想法是通过截取的方式进行数组 ...

  7. Qt QDataTime QString 两个类的使用

    QDateTime now = QDateTime::currentDateTime(); QString nowStr; nowStr = now.toString("yyyyMMdd_h ...

  8. discuz模板引擎

    discuz是采用“编译型的模板”,就是指采用普通网页文件保存,在文件中插入需要动态显示数据的仿php的代码,最后进行编译成真正的php的文件保存为模板缓存文件,这个转换的过程就称为编译.在用户浏览页 ...

  9. bootstrap 带有确定取消按钮的modal

    </div><div class="modal fade" id="confirmModal" tabindex="-1" ...

  10. Promise学习探究

    学习熟知吧,原理还是继续吧 例子1: var isGeted; function getRet(){ return new Promise(function(resolve, reject) { // ...