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. scikit-learn:4.5. Random Projection

    參考:http://scikit-learn.org/stable/modules/random_projection.html The sklearn.random_projection modul ...

  2. php的ord函数——解决中文字符截断问题

    php的ord函数——解决中文字符截断问题 分类: PHP2014-11-26 12:11 1033人阅读 评论(0) 收藏 举报 utf8字符截取 函数是这样定义的: int ord ( strin ...

  3. layui关闭layer.open打开的页面

    var index = parent.layer.getFrameIndex(window.name); //获取窗口索引parent.layer.close(index);

  4. FreeRTOS——任务调度—抢占式,时间片和合作式

    以下转载自安富莱电子: http://forum.armfly.com/forum.php 本章教程为大家将介绍 FreeRTOS 操作系统支持的任务调度方式:抢占式,时间片和合作式,这部分算是 Fr ...

  5. 动易cms .net版本后台拿shell

    PS:前提是要有IIS6.0的析漏洞 网上我找了好一会儿没有找到.直奔主题.至于怎么弄到密码,全靠坑蒙拐骗. 系统设置=>模板标签管理=>模板管理 然后选则上传模板(如果新建的话会被限制掉 ...

  6. 【Hadoop】HA 场景下访问 HDFS JAVA API Client

    客户端需要指定ns名称,节点配置,ConfiguredFailoverProxyProvider等信息. 代码示例: package cn.itacst.hadoop.hdfs; import jav ...

  7. 实现itoa()

    上代码之前先讲个笑话:曾经有位面试官问:“你实现过 唉踢哦诶(音) 吗”? 我第一个想到的是各种OA系统,心想那玩意不多是Java实现的吗...过一会想明白了,瞬间石化... #include < ...

  8. [Shell Script]关于source和sh对于脚本执行不同

    当我修改了/etc/profile文件,我想让它立刻生效,而不用重新登录:这时就想到用source命令,如:source /etc/profile对source进行了学习,并且用它与sh 执行脚本进行 ...

  9. 在MySQL应用上的挑战

    本期采访的讲师是来自腾讯高级软件工程师 雷海林,他有着10年以上的Linux后台Server开发经验,目前主要从事分布式Cache.实时大数据处理引擎,分布式MySQL(TDSQL)设计和开发工作. ...

  10. Linux crontab 实现每秒执行

    Linux crontab 实现每秒执行 linux crontab 命令,最小的执行时间是一分钟.如需要在小于一分钟内重复执行,可以有两个方法实现. 1.使用延时来实现每N秒执行 创建一个php做执 ...