Codeforces Round #426 (Div. 2)A题&&B题&&C题
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题的更多相关文章
- CodeForces 834C - The Meaningless Game | Codeforces Round #426 (Div. 2)
/* CodeForces 834C - The Meaningless Game [ 分析,数学 ] | Codeforces Round #426 (Div. 2) 题意: 一对数字 a,b 能不 ...
- 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 ...
- 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 ...
- Codeforces Round #426 (Div. 2)A B C题+赛后小结
最近比赛有点多,可是好像每场比赛都是被虐,单纯磨砺心态的作用.最近讲的内容也有点多,即便是点到为止很浅显的版块,刷了专题之后的状态还是~"咦,能做,可是并没有把握能A啊".每场网络 ...
- 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 ...
- 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) C. The Meaningless Game
C. The Meaningless Game 题意: 两个人刚刚开始游戏的时候的分数, 都是一分, 然后随机一个人的分数扩大k倍,另一个扩大k的平方倍, 问给你一组最后得分,问能不能通过游戏得到这样 ...
- Codeforces Round #384 (Div. 2) C. Vladik and fractions 构造题
C. Vladik and fractions 题目链接 http://codeforces.com/contest/743/problem/C 题面 Vladik and Chloe decided ...
- 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 ...
随机推荐
- 危险系数 set容器
题目描述 抗日战争时期,冀中平原的地道战曾发挥重要作用. 地道的多个站点间有通道连接,形成了庞大的网络.但也有隐患,当敌人发现了某个站点后,其它站点间可能因此会失去联系. 我们来定义一个危险系数DF( ...
- git 的一些笔记
git config git config存在三个地方 :1./.git/config 项目级别2.~/.gitconfig 用户级别3./etc/gitconfig 系统级别 git config ...
- [转]ISTQB FL初级认证考试资料(中文)
[转]ISTQB FL初级认证考试资料(中文) 2015-06-22 ISTQB作为一个专业的提供软件测试认证的机构,得到了全球软件测试人员的认可.目前中国有越来越多的人已经获得或者希望获得ISTQB ...
- 在linux下监控文件是否被删除或创建的命令
You can use auditd and add a rule for that file to be watched: auditctl -w /path/to/that/file -p wa ...
- hdu 1006 Tick and Tick 有技巧的暴力
Tick and Tick Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tot ...
- 时间同步linux和window
windows和linux都可以通过ntp服务,同步时间.
- SpringMVC请求后台地址URL没有.*的几种实现方式
今天做项目,由于项目是通过扫二维码进入,二维码存放的地址不希望有 .do,而是http:xxxx:8080/xxx/yyy/zzz的格式(zzz为参数),但是项目其它请求url后面都必须要有.do,想 ...
- JDK1.8与spring3.x的不兼容
今天运气很好,两次遇到了这个兼容性问题,spring3.x不支持 java 1.8 byte code format!! 九月 10, 2017 7:17:18 上午 org.apache.catal ...
- EasyUI 表单 tree
第一步:创建HTML标记 <divid="dlg"style="padding:20px;"> <h2>Account Info ...
- javax.Servlet的包中,属于类的是。(选择1项)
javax.Servlet的包中,属于类的是.(选择1项) A.Servlet B.GenericServlet C.ServletRequest D.ServletContext 解答:B Serv ...