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. 【原创】k8s源代码分析-----kubelet(1)主要流程

    本人空间链接http://user.qzone.qq.com/29185807/blog/1460015727 源代码为k8s v1.1.1稳定版本号 kubelet代码比較复杂.主要是由于其担负的任 ...

  2. JQM事件详解

    在前文<使用 jQuery Mobile 与 HTML5 开发 Web App —— jQuery Mobile 默认配置与事件基础>中,Kayo 对 jQuery Mobile 事件的基 ...

  3. 内存控制函数(1)-mmap() 建立内存映射

    示例1: 1.首先建立一个文本文件,名字为tmp,内容为hello world 2.编写mmap.c #include <sys/types.h> #include <sys/sta ...

  4. Nginx - rewrite 不区分大小写进行匹配

    Nginx - rewrite 不区分大小写进行匹配 分类: Nginx2014-05-28 19:25 1046人阅读 评论(0) 收藏 举报 Use (?i) to match case-inse ...

  5. jq实现千分位的转换

    一.千分位转换位整数 var sum = '2,034,300';var x = sum.split(",");var plan_sum = parseFloat(x.join(& ...

  6. CentOS6.2 下安装OpenGL开发库

    在Linux下做Qt开发,结果运行程序的时候提示找不到GL/gl.h文件,所以只能先把OpenGL库安装上去,不知道这样操作对不对,以后再考虑吧,下面开始安装 1.查看mesa相关的包 yum lis ...

  7. SQLite的连接字符串

    SQLite的连接字符串 Basic(基本的)     Data Source=filename;Version=3;Using UTF16(使用UTF16编码)    Data Source=fil ...

  8. (转)love2d有用的辅助库--gamework

    此文转自朱大仙,感谢他的劳作. 翻译来源地址:https://github.com/Kadoba/gamework gamework是控制LOVE2D游戏进程流的一个项目. ↑ 这个是按原文译的, 当 ...

  9. C# XCOPY命令 预先生成事件命令行”和“后期生成事件命令行”

    $(ConfigurationName) 当前项目配置的名称(例如,“Debug|Any CPU”). $(OutDir) 输出文件目录的路径,相对于项目目录.这解析为“输出目录”属性的值.它包括尾部 ...

  10. 使用jQuery模拟Google的自动提示效果

    注意: 1.本功能使用SqlServler2000中的示例数据库Northwind,请打SP3或SP4补丁:2.请下载jQuery组件,河西FTP中有下载:3.本功能实现类似Google自动提示的效果 ...