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. Windows剪贴板操作简单小例

    1.复制文字到剪贴板 CString strText = L"须要拷贝到剪贴板的文字"; if ( ::OpenClipboard(m_hWnd) ) { if ( ::Empty ...

  2. 信号处理函数(1)-alarm定时器

    定义: unsigned int alarm(unsigned int seconds);   表头文件: #include<unistd.h>   说明: alarm()用来设置信号SI ...

  3. HttpURLConnection上传文件

    HttpURLConnection上传文件 import java.io.BufferedReader; import java.io.DataInputStream; import java.io. ...

  4. 【鉴别】日版iPhone如何通过IMEI查询运营商

    SoftBank.au.docomo是日本的三大运营商,以前日本不同运营商的iPhone在型号上进行区分,但iPhone5s/5c上三个运营商的型号都一致,所以无法在型号上对运营商进行区分,本文介绍通 ...

  5. Git中保存用户名和密码

    每次操作都需要输入用户名和密码感觉很繁琐,解决方法,在本地的工程文件夹的.git下打开config文件添加: [credential]     helper = store 再输入一次用户名密码后就可 ...

  6. mysql5.5和5.6版本间的坑

    mysql 5.5 int类型 设置不为null,无填充,添加新数据会自动填充0 而5.6同样的配置新建数据没值时,不让添加 5.5 datetime 不能设置默认时间(可以通过某些复杂的方式,这里说 ...

  7. Unix系统编程()原子操作和竞争条件

    竞争状态是这样一种情形:操作共享资源的两个进程(或线程),其结果取决于一个无法预期的顺序,即这些进程获得CPU使用权的先后相对顺序. 以独占的方式创建一个文件 当同时指定了O_EXCL和O_CREAT ...

  8. Linux下清空缓冲区的方法

    Linux下清空缓冲区的方法 C标准规定fflush()函数是用来刷新输出(stdout)缓存的.对于输入(stdin),它是没有定义的.但是有些编译器也定义了fflush( stdin )的实现,比 ...

  9. ssdfd

    http://www.phpweb.net/ http://wenku.baidu.com/view/6044c67c27284b73f242506b.htmlhttp://www.jb51.net/ ...

  10. UCASE() 函数

    UCASE() 函数 UCASE 函数把字段的值转换为大写. SQL UCASE() 语法 SELECT UCASE(column_name) FROM table_name