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,是顺时 ...
随机推荐
- LeetCode-206.ReverseLinked List
Reverse a singly linked list. Example: Input: 1->2->3->4->5->NULL Output: 5->4-> ...
- python中操作mysql
import pymysql # 连接数据库 connect = pymysql.Connect( host='localhost', port=3306, user='root', passwd=' ...
- 事务控制及try catch
一.事务控制 BEGIN TRY BEGIN TRAN; DECLARE @aaa NVARCHAR(MAX); SET @aaa = 9 / 0; COMMIT TRAN;END TRYBEGIN ...
- .NET Core 2.0 官方下载地址及中文教程
开发.net core 应用需要安装.NET Core 2.0 SDK http://www.microsoft.com/net/download/core#/sdk 电脑上运行 .net core ...
- [py]字符串/列表
去除str首尾空格(切片) ## str长度 循环,判断 ### [:i] [i:] 记录位置点 ## 方法1 def trim2(s): s2 = "" start = 0 en ...
- [LeetCode] 252. Meeting Rooms_Easy tag: Sort
Given an array of meeting time intervals consisting of start and end times [[s1,e1],[s2,e2],...] (si ...
- [Leetcode] 863. All Nodes Distance K in Binary Tree_ Medium tag: BFS, Amazon
We are given a binary tree (with root node root), a target node, and an integer value `K`. Return a ...
- unity3D中 material中tiling和offset属性解释
贴图有可能是多行多列的一些图案组成的.当我们需要一帧,一帧的播放时候.也就是帧序列动画, 我们就需要用到tiling和offset两个属性, 默认图片的左下角为坐标圆点即:(0,0) tiling是图 ...
- Unirest-拼装http请求发送rest接口
public static Integer getInfo(String name) { HttpResponse<Integer> httpResponse = null; try { ...
- Multinoulli distribution
https://www.statlect.com/probability-distributions/multinoulli-distribution3 Multinoulli distributio ...