Codeforces Round #426 (Div. 2) A,B,C
A. The Useless Toy
题目链接:http://codeforces.com/contest/834/problem/A
思路: 水题
实现代码:
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>
#include<set>
#include<list>
using namespace std;
#define ll long long
#define sd(x) scanf("%d",&x)
#define sdd(x,y) scanf("%d%d",&x,&y)
#define sddd(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define sf(x) scanf("%s",x)
#define ff(i,x,y) for(int i = x;i <= y;i ++)
#define fj(i,x,y) for(int i = x;i >= y;i --)
#define mem(s,x) memset(s,x,sizeof(s));
#define pr(x) printf("%d",x);
const int Mod = 1e9+;
const int inf = 1e9;
const int Max = 1e5+;
void exgcd(ll a,ll b,ll& d,ll& x,ll& y){if(!b){d=a;x=;y=;}else{exgcd(b,a%b,d,y,x);y-=x*(a/b);}}
ll inv(ll a,ll n){ll d, x, y;exgcd(a,n,d,x,y);return (x+n)%n;}
int gcd(int a,int b) { return (b>)?gcd(b,a%b):a; }
int lcm(int a, int b) { return a*b/gcd(a, b); }
ll mod(ll x,ll y){
return x-(x/y)*y;
}
int main()
{
ios::sync_with_stdio();
cin.tie();
char a[];
ll k,b[];
cin>>a[]>>a[];
cin>>k;
for(int i=;i<=;i++){
if(a[i]=='v') b[i] = ;
if(a[i]=='<') b[i] = ;
if(a[i]=='^') b[i] = ;
if(a[i]=='>') b[i] = ;
}
ll ans1 = mod(k+b[],);
ll ans2 = mod(b[]-k,);
while(ans2<)
ans2+=;
if(b[]==ans1&&b[]==ans2)
cout<<"undefined"<<endl;
else if(b[]==ans2)
cout<<"ccw"<<endl;
else if(b[]==ans1)
cout<<"cw"<<endl;
return ;
}
B. The Festive Evening
题目链接:http://codeforces.com/contest/834/problem/B
思路; 水题
实现代码:
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>
#include<set>
#include<list>
using namespace std;
#define ll long long
#define sd(x) scanf("%d",&x)
#define sdd(x,y) scanf("%d%d",&x,&y)
#define sddd(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define sf(x) scanf("%s",x)
#define ff(i,x,y) for(int i = x;i <= y;i ++)
#define fj(i,x,y) for(int i = x;i >= y;i --)
#define mem(s,x) memset(s,x,sizeof(s));
#define pr(x) printf("%d",x);
const int Mod = 1e9+;
const int inf = 1e9;
const int Max = 1e5+;
void exgcd(ll a,ll b,ll& d,ll& x,ll& y){if(!b){d=a;x=;y=;}else{exgcd(b,a%b,d,y,x);y-=x*(a/b);}}
ll inv(ll a,ll n){ll d, x, y;exgcd(a,n,d,x,y);return (x+n)%n;}
int gcd(int a,int b) { return (b>)?gcd(b,a%b):a; }
int lcm(int a, int b) { return a*b/gcd(a, b); }
ll mod(ll x,ll y){ return x-(x/y)*y;}
char s[];
map<char,int>mp;
set<char>st;
int main()
{
int n,m,cnt=,i,vis[];
ios::sync_with_stdio();
cin.tie();
cin>>n>>m;
mp.size();
for(i=;i<n;i++){
cin>>s[i];
mp[s[i]]=i;
}
for(i=;i<n-;i++){
st.insert(s[i]);
if(st.size()>m){
cout<<"YES"<<endl;
return ;
}
if(mp[s[i]]==i)
st.erase(s[i]);
}
cout<<"NO"<<endl;
return ;
}
C. The Meaningless Game
题目链接:http://codeforces.com/contest/834/problem/C
思路:二分,a,b分别*k或*k^2,那么a*b必为k*(k^2)*(k1^2)*k1*.....也就是 (k*k1*..)^3,直接二分搜a*b是否为某个数的三次方,输入输出数据比较大,用scanf和print.要不超时
实现代码:
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>
#include<set>
#include<list>
using namespace std;
#define ll long long
#define sd(x) scanf("%d",&x)
#define sdd(x,y) scanf("%d%d",&x,&y)
#define sddd(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define sf(x) scanf("%s",x)
#define ff(i,x,y) for(int i = x;i <= y;i ++)
#define fj(i,x,y) for(int i = x;i >= y;i --)
#define mem(s,x) memset(s,x,sizeof(s));
#define pr(x) printf("%d",x);
const int Mod = 1e9+;
const int inf = 1e9;
const int Max = 1e5+;
void exgcd(ll a,ll b,ll& d,ll& x,ll& y){if(!b){d=a;x=;y=;}else{exgcd(b,a%b,d,y,x);y-=x*(a/b);}}
ll inv(ll a,ll n){ll d, x, y;exgcd(a,n,d,x,y);return (x+n)%n;}
int gcd(int a,int b) { return (b>)?gcd(b,a%b):a; }
int lcm(int a, int b) { return a*b/gcd(a, b); }
int main()
{
ll n,i,mid,l,r,a,b;
cin>>n;
for(i=;i<n;i++){
scanf("%I64d %I64d",&a,&b);
l=;r=;
int flag = ;
while(l<=r){
mid = (l+r)/;
//cout<<Pow(mid,3)<<" "<<a*b<<endl;
if(mid*mid*mid==a*b){
flag = ;break;}
if(mid*mid*mid>a*b)
r = mid-;
if(mid*mid*mid<a*b)
l = mid+;
}
if(flag&&a*a%b==&&b*b%a==)
printf("Yes\n");
else
printf("No\n");
}
return ;
}
Codeforces Round #426 (Div. 2) A,B,C的更多相关文章
- 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)【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) C. The Meaningless Game
C. The Meaningless Game 题意: 两个人刚刚开始游戏的时候的分数, 都是一分, 然后随机一个人的分数扩大k倍,另一个扩大k的平方倍, 问给你一组最后得分,问能不能通过游戏得到这样 ...
- 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 题目意思:给你两个字符,还有一个n,问你旋转n次以后从字符a变成b,是顺时 ...
- 【Codeforces Round #426 (Div. 2) A】The Useless Toy
[Link]:http://codeforces.com/contest/834/problem/A [Description] [Solution] 开个大小为4的常量字符数组; +n然后余4,-n ...
- 【Codeforces Round #426 (Div. 2) B】The Festive Evening
[Link]:http://codeforces.com/contest/834/problem/B [Description] [Solution] 模拟水题; 注意一个字母单个出现的时候,结束和开 ...
- 【Codeforces Round #426 (Div. 2) C】The Meaningless Game
[Link]:http://codeforces.com/contest/834/problem/C [Description] 有一个两人游戏游戏; 游戏包括多轮,每一轮都有一个数字k,赢的人把自己 ...
随机推荐
- Luogu4423 BJWC2011 最小三角形 平面最近点对
传送门 题意:给出$N$个点,求其中周长最小的三角形(共线的也计算在内).$N \leq 2 \times 10^5$ 这道题唤起了我对平面最近点对的依稀记忆 考虑平面最近点对的分治,将分界线两边的求 ...
- 使用yield返回IEnumber<T>集合
yield是对一种复杂行为的简化,就是将一段代码简化为一种简单的形式. 先看一下常规的写法,下面例子中,把找出字符串阵列中,某些元素包含有某些字符的元素. class Bi { public stri ...
- 使用sklearn进行K_Means聚类算法
首先附上官网说明 [http://scikit-learn.org/stable/modules/generated/sklearn.cluster.KMeans.html#examples-usin ...
- 校内模拟赛 Attack's Fond Of LeTri
Attack's Fond Of LeTri 题意: n个房子m条路径边的无向图,每个房子可以最终容纳b个人,初始有a个人,中途超过可以超过b个人,每条边有一个长度,经过一条边的时间花费为边的长度.求 ...
- 案例学python——案例一:抓图
最近项目不那么紧张,有时间来研究一下Python,先前断断续续的自学了一段时间,有些浅基础.刚好在码云上看到比较适合的案例,跟着案例再往前走一波. 案例一:爬虫抓图 开发工具:PyCharm 脚 ...
- 【IDEA】Intellij IDEA创建的Web项目配置Tomcat并启动Maven项目
转载请注明出处:http://blog.csdn.net/qq_26525215本文源自[大学之旅_谙忆的博客] 本篇博客讲解IDEA如何配置Tomcat. 大部分是直接上图哦. 点击如图所示的地方, ...
- 【转】Git版本控制软件从入门到精通学习手册
GIT 学习手册简介 本站为 Git 学习参考手册.目的是为学习与记忆 Git 使用中最重要.最普遍的命令提供快速翻阅. 这些命令以你可能需要的操作类型划分,并且将提供日常使用中需要的一些常用的命令以 ...
- 2018年高教社杯全国大学生数学建模竞赛C题解题思路
题目 C题 大型百货商场会员画像描绘 在零售行业中,会员价值体现在持续不断地为零售运营商带来稳定的销售额和利润,同时也为零售运营商策略的制定提供数据支持.零售行业会采取各种不同方法来吸引更多的人成 ...
- list 的 增 删
增: 1. name = [] 2. name.append() 3. name.extend(name2) name2为可迭代的 name + name2 与之效果一样,合并为一个列表 4. nam ...
- ZooKeeper 典型的应用场景——及编程实现
如何使用 Zookeeper 作为一个分布式的服务框架,主要用来解决分布式集群中应用系统的一致性问题,它能提供基于类似于文件系统的目录节点树方式的数据存储,但是 Zookeeper 并不是用来专门存储 ...