A. The Useless Toy:http://codeforces.com/contest/834/problem/A

题目意思:给你两个字符,还有一个n,问你旋转n次以后从字符a变成b,是顺时针还是逆时针还是无法确定。

思路: 直接把c=n%4,然后搞出a->b需要顺时针转x下, 那么4-x就是逆时针需要转多少下了,如果顺逆时间是一样的 ,肯定无法判断,如果等于其中一个那该顺时针顺时针,该逆时针逆时针,如果两个时间都不等于c那就是不确定了。   还有一点如果一开始a=b,那就不需要判断肯定是确定了,如果n=0了话,肯定也是不确定了。

代码:

 //Author: xiaowuga
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <queue>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <map>
#include <bitset>
#include <cctype>
#define maxx INT_MAX
#define minn INT_MIN
#define inf 0x3f3f3f3f
#define mem(s,ch) memset(s,ch,sizeof(s))
const long long N=;
using namespace std;
typedef long long LL;
map<char,int>q;
int main() {
ios::sync_with_stdio(false);cin.tie();
char s[]={'^','>','v','<','^','>','v','<'};
q['^']=;q['>']=;q['v']=;q['<']=;
char a,b,t;
int n;
cin>>a>>b>>n;
if(n==) {cout<<"undefined"<<endl;return ;}
if(a==b) {cout<<"undefined"<<endl;return ;}
int p1;
for(int i=q[a];i<;i++){
if(s[i]==b){ p1=i-q[a];break;}
}
int c=n%;
if(c==p1||c==-p1){
if(c==p1&&c==-p1) cout<<"undefined"<<endl;
else if(c==p1) cout<<"cw"<<endl;
else cout<<"ccw"<<endl;
}
return ;
}

B. The Festive Evening:http://codeforces.com/contest/834/problem/B

题目意思:一个城堡里面有26个门,分别用26个大写字母表示。现在不同的宾客用不同大写字母表示,相应字母的客人从相应的门进入,客人的到来按照字符串的顺序。在一个某一个字母的大门第一个客人来到最后一个客人来之前这个门都需要一个士兵把守,但是现在城堡只有k个士兵,问是否存在士兵不够用的前情况。

思路:先把字符串从头到尾扫一遍看一下,每一个字母最后一个出现的位置在哪里把他记录一下。然后再从头到尾扫一遍,开一个vis数组记录第一个客人是否已经来了。如果来了之前没有出现过的字母ct++,如果这个当前位置已经是这个颜色的最后一个位置ct--,去判断这个过程中ct的最大值和k比较,就可以得到答案。

代码:

 //Author: xiaowuga
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <queue>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <map>
#include <bitset>
#include <cctype>
#define maxx INT_MAX
#define minn INT_MIN
#define inf 0x3f3f3f3f
#define mem(s,ch) memset(s,ch,sizeof(s))
#define da cout<<da<<endl
#define uoutput(a,i,l,r) for(int i=l;i<r;i++) if(i==l) cout<<a[i];else cout<<" "<<a[i];cout<<endl;
#define doutput(a,i,l,r) for(int i=r-1;i>=0;i--) if(i==r-1) cout<<a[i];else cout<<" "<<a[i];cout<<endl;
const long long N=;
using namespace std;
typedef long long LL;
int vis[N]={};
int en[N]={};
int main() {
ios::sync_with_stdio(false);cin.tie();
int n,k;
cin>>n>>k;
char q[+];
cin>>q;
for(int i=;i<n;i++){
char t=q[i]-'A';
en[t]=i;
}
int ct=,mm=minn;
for(int i=;i<n;i++){
char t=q[i]-'A';
if(!vis[t]) {ct++;vis[t]=;}
mm=max(mm,ct);
if(i==en[t]) ct--;
}
if(k<mm) cout<<"YES"<<endl;
else cout<<"NO"<<endl;
return ;
}

C. The Meaningless Game:http://codeforces.com/contest/834/problem/C

题目意思:每次给两个数a,b问是否满足他的游戏规律所得出来的结果。游戏规律就是每一轮出一个k,赢的一方乘k^2,输的一方乘k,然后你说会否可以找出一个系列的k可以满足a,b这个游戏结果。

思路:数学题,这个很明显就是a*b=(k1*k2*k3*k4*k4*k5*k6*k7…………kn)^3,自己xjb推一下就会发现,我做不出来的问题在于不知道如何判断一个数是一个立方数。

做法:直接把LL  x=floor(pow(a*b,1.0/3)+0.5),+0.5是四舍五入的套路以后记住就好了,这样算就可以开三方,然后反向验证x*x*x是否等于a*b就解决了,还有一个cbrt()函数是直接开三方的之前不知道,现在学会了,输入量比较多,所以用了一个究极输入挂。

代码:

 //Author: xiaowuga
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <queue>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <map>
#include <bitset>
#include <cctype>
#define maxx INT_MAX
#define minn INT_MIN
#define inf 0x3f3f3f3f
#define mem(s,ch) memset(s,ch,sizeof(s))
#define da cout<<da<<endl
#define uoutput(a,i,l,r) for(int i=l;i<r;i++) if(i==l) cout<<a[i];else cout<<" "<<a[i];cout<<endl;
#define doutput(a,i,l,r) for(int i=r-1;i>=0;i--) if(i==r-1) cout<<a[i];else cout<<" "<<a[i];cout<<endl;
const long long N=;
using namespace std;
typedef long long LL;
const int MAXBUF = ;
char buf[MAXBUF], *ps = buf, *pe = buf+; inline void rnext()
{
if(++ps == pe)
pe = (ps = buf)+fread(buf,sizeof(char),sizeof(buf)/sizeof(char),stdin);
} template <class T>
inline bool readin(T &ans)
{
ans = ;
T f = ;
if(ps == pe) return false;//EOF
do{
rnext();
if('-' == *ps) f = -;
}while(!isdigit(*ps) && ps != pe);
if(ps == pe) return false;//EOF
do
{
ans = (ans<<)+(ans<<)+*ps-;
rnext();
}while(isdigit(*ps) && ps != pe);
ans *= f;
return true;
}
int main() {
ios::sync_with_stdio(false);cin.tie();
LL a,b;
LL n;
readin(n);
while(n--){
readin(a);readin(b);
LL t=a*b;
LL x=floor(pow(1.0*t,1.0/)+0.5);
if(x*x*x!=t||a%x||b%x) puts("NO");
else puts("YES");
}
return ;
}

Codeforces Round #426 (Div. 2)A题&&B题&&C题的更多相关文章

  1. CodeForces 834C - The Meaningless Game | Codeforces Round #426 (Div. 2)

    /* CodeForces 834C - The Meaningless Game [ 分析,数学 ] | Codeforces Round #426 (Div. 2) 题意: 一对数字 a,b 能不 ...

  2. Codeforces Round #297 (Div. 2)A. Vitaliy and Pie 水题

    Codeforces Round #297 (Div. 2)A. Vitaliy and Pie Time Limit: 2 Sec  Memory Limit: 256 MBSubmit: xxx  ...

  3. Codeforces Round #298 (Div. 2) A、B、C题

    题目链接:Codeforces Round #298 (Div. 2) A. Exam An exam for n students will take place in a long and nar ...

  4. Codeforces Round #426 (Div. 2)A B C题+赛后小结

    最近比赛有点多,可是好像每场比赛都是被虐,单纯磨砺心态的作用.最近讲的内容也有点多,即便是点到为止很浅显的版块,刷了专题之后的状态还是~"咦,能做,可是并没有把握能A啊".每场网络 ...

  5. Codeforces Round #426 (Div. 2) B题【差分数组搞一搞】

    B. The Festive Evening It's the end of July – the time when a festive evening is held at Jelly Castl ...

  6. 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 ...

  7. Codeforces Round #426 (Div. 2) C. The Meaningless Game

    C. The Meaningless Game 题意: 两个人刚刚开始游戏的时候的分数, 都是一分, 然后随机一个人的分数扩大k倍,另一个扩大k的平方倍, 问给你一组最后得分,问能不能通过游戏得到这样 ...

  8. Codeforces Round #384 (Div. 2) C. Vladik and fractions 构造题

    C. Vladik and fractions 题目链接 http://codeforces.com/contest/743/problem/C 题面 Vladik and Chloe decided ...

  9. Codeforces Round #384 (Div. 2) A. Vladik and flights 水题

    A. Vladik and flights 题目链接 http://codeforces.com/contest/743/problem/A 题面 Vladik is a competitive pr ...

随机推荐

  1. Objective-c的@property 详解

    转自:http://www.cnblogs.com/andyque/archive/2011/08/03/2125728.html 之前很多网友对我翻译的教程中的Property的使用感到有些迷惑不解 ...

  2. 记一次线上MySQL数据库死锁问题

            最近线上项目报了一个MySQL死锁(DealLock)错误,虽说对业务上是没有什么影响的,由于自己对数据库锁这块了解不是很多,之前也没怎么的在线上碰到过.这次刚好遇到了,便在此记录一下 ...

  3. oracle 存储过程学习感悟

    1.跟大白话差不多 2.if...then.... else ....写的比较多 3.调用存储过程命令:execute procedure_name 4.调用存储函数命令:select '0' str ...

  4. CSS学习笔记(9)--详解CSS中:nth-child的用法

    详解CSS中:nth-child的用法 前端的哥们想必都接触过css中一个神奇的玩意,可以轻松选取你想要的标签并给与修改添加样式,是不是很给力,它就是“:nth-child”. 下面我将用几个典型的实 ...

  5. 基于css3的鼠标经过动画显示详情特效

    之前为大家分享过一款基于jquery的手风琴显示详情,今天给大家分享基于css3的鼠标经过动画显示详情特效.这款实例鼠标经过的时候基于中间动画放大,效果非常不错,效果图如下: 在线预览   源码下载 ...

  6. java web 自定义filter

    filter顾名思义,过滤器的意思,在javaweb中的Struts就利用了这种机制去实现视图和业务分离. 这里来配置下自己的Filter来理解下Struts的内在. 在web.xml 中添加下面: ...

  7. gpio 灯的对应关系

    1 点灯验证通过:   GPIO160     TX1-LED GPIO161     RX1-LED   GPIO163     TX2-LED GPIO164     RX2-LED   GPIO ...

  8. mysql中创建用户和赋权限

    mysql命令行用的不多,大部分使用工具类替代,所以这里记录下命令行模式下创建用户和赋予权限的命令,不用每次麻烦百度. 1. 创建oozie用户,%符号表示仅限于远程登录 create user 'o ...

  9. 29个酷炫的Firefox配置参数

    你可能安装了许多的firefox插件以增加浏览器的功能,但是如果你想更好地使用firefox,学习如何配置about:config参数是很有必要的. about:config配置页包含了所有的fire ...

  10. 数学 + 带权中位数 - SGU 114 Telecasting station

    Telecasting station Problem's Link Mean: 百慕大的每一座城市都坐落在一维直线上,这个国家的政府决定建造一个新的广播电视台. 经过了许多次试验后,百慕大的科学家们 ...