Codeforces Round #426 (Div. 2) C. The Meaningless Game
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的更多相关文章
- Codeforces Round #426 (Div. 1) A.The Meaningless Game (二分+数学)
题目链接: http://codeforces.com/problemset/problem/833/A 题意: 给你 \(a\) 和 \(b\),两个人初始化为 \(1\).两个人其中一方乘以 \( ...
- 【筛法求素数】Codeforces Round #426 (Div. 1) A. The Meaningless Game
先筛出来1000以内的素数. 枚举x^(1/3) 和 y^(1/3)以内的素因子,这样除完以后对于x和y剩下的因子,小的那个的平方必须等于大的. 然后判断每个素因数的次数之和是否为3的倍数,并且小的那 ...
- CodeForces 834C - The Meaningless Game | Codeforces Round #426 (Div. 2)
/* CodeForces 834C - The Meaningless Game [ 分析,数学 ] | Codeforces Round #426 (Div. 2) 题意: 一对数字 a,b 能不 ...
- 【Codeforces Round #426 (Div. 2) C】The Meaningless Game
[Link]:http://codeforces.com/contest/834/problem/C [Description] 有一个两人游戏游戏; 游戏包括多轮,每一轮都有一个数字k,赢的人把自己 ...
- 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 ...
- Codeforces Round #426 (Div. 2)
http://codeforces.com/contest/834 A. The Useless Toy 题意: <,>,^,v这4个箭头符号,每一个都可以通过其他及其本身逆时针或者顺时针 ...
- Codeforces Round #426 (Div. 2)A B C题+赛后小结
最近比赛有点多,可是好像每场比赛都是被虐,单纯磨砺心态的作用.最近讲的内容也有点多,即便是点到为止很浅显的版块,刷了专题之后的状态还是~"咦,能做,可是并没有把握能A啊".每场网络 ...
- Codeforces Round #426 (Div. 2) A,B,C
A. The Useless Toy 题目链接:http://codeforces.com/contest/834/problem/A 思路: 水题 实现代码: #include<bits/st ...
- Codeforces Round #426 (Div. 2)A题&&B题&&C题
A. The Useless Toy:http://codeforces.com/contest/834/problem/A 题目意思:给你两个字符,还有一个n,问你旋转n次以后从字符a变成b,是顺时 ...
随机推荐
- IO流(9)复制指定文件夹下指定文件到目的文件夹,并改名
import java.io.BufferedInputStream;import java.io.BufferedOutputStream;import java.io.File;import ja ...
- oracle(四) 常用语句
1.分页 select t2.* from (select rownum row, t1.* from your_table where rownum < ?) t2 where t2.row ...
- javascript-js模拟form页面提交跳转
window.location.href跳转到另外一个界面.但直接传递get方法会暴露数据 下面可以实现跳转的效果,却又能够通过post传递方法隐藏数据. 有一个不足就是,在跳转到新页面后,点击“返回 ...
- (转)FastDFS文件存储
一.FastDFS介绍 FastDFS开源地址:https://github.com/happyfish100 参考:分布式文件系统FastDFS设计原理 参考:FastDFS分布式文件系统 个人封装 ...
- Selenium之Css Selector使用方法
什么是Css Selector? Css Selector定位实际就是HTML的Css选择器的标签定位 工具 Css Selector的练习建议使用火狐浏览器,下载插件,FireFinder.Fire ...
- (转)Springboot 中filter 注入对象
问题:我建立一个全局拦截器,当然,这是测试的时候建立的,我把它命名为LogFilter,它继承了Filter,web应用启动的顺序是:listener->filter->servlet,而 ...
- 使用Python2.7 POST 数据到 onenet 平台
功能 发送数据名称为SENSORID(这里用TEST测试),数值为VALUE(这里用49值做测试)的数据,发送到自己的onenet对应设备 效果发送成功 代码 # -*- coding: utf-8 ...
- How to enable TLS 1.2 on Windows Server 2008 R2
Problem How to enable TLS 1.2 on Windows Server 2008 R2? Resolution QuoVadis recommends enabling and ...
- vs2015 相关
VS2015一共有3个版本,Visual Studio Community(社区版).Visual Studio Professional(专业版).Visual Studio Enterprise( ...
- ide vscode安装
在linux系统中安装VSCode(Visual Studio Code) 在linux系统中安装VSCode(Visual Studio Code) 1.从官网下载压缩包(话说下载下来解压就直接 ...