Educational Codeforces Round 33 (Rated for Div. 2)
1 second
256 megabytes
standard input
standard output
Alex, Bob and Carl will soon participate in a team chess tournament. Since they are all in the same team, they have decided to practise really hard before the tournament. But it's a bit difficult for them because chess is a game for two players, not three.
So they play with each other according to following rules:
- Alex and Bob play the first game, and Carl is spectating;
- When the game ends, the one who lost the game becomes the spectator in the next game, and the one who was spectating plays against the winner.
Alex, Bob and Carl play in such a way that there are no draws.
Today they have played n games, and for each of these games they remember who was the winner. They decided to make up a log of games describing who won each game. But now they doubt if the information in the log is correct, and they want to know if the situation described in the log they made up was possible (that is, no game is won by someone who is spectating if Alex, Bob and Carl play according to the rules). Help them to check it!
The first line contains one integer n (1 ≤ n ≤ 100) — the number of games Alex, Bob and Carl played.
Then n lines follow, describing the game log. i-th line contains one integer ai (1 ≤ ai ≤ 3) which is equal to 1 if Alex won i-th game, to 2 if Bob won i-th game and 3 if Carl won i-th game.
Print YES if the situation described in the log was possible. Otherwise print NO.
3
1
1
2
YES
2
1
2
NO
In the first example the possible situation is:
- Alex wins, Carl starts playing instead of Bob;
- Alex wins, Bob replaces Carl;
- Bob wins.
The situation in the second example is impossible because Bob loses the first game, so he cannot win the second one.
三个人 比赛,两个人下棋 一个人旁观,下棋之后输的人去旁观,胜的人和之前旁观的人比赛下棋 。模拟下就可以了
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin>>n;
int ans=;
for(int i=; i<n; ++i)
{
int x;
cin>>x;
if(x==ans)
{
cout<<"NO\n";
return ;
}
ans=-x-ans;
}
cout<<"YES\n";
return ;
}
2 seconds
256 megabytes
standard input
standard output
Recently Luba learned about a special kind of numbers that she calls beautiful numbers. The number is called beautiful iff its binary representation consists of k + 1 consecutive ones, and then k consecutive zeroes.
Some examples of beautiful numbers:
- 12 (110);
- 1102 (610);
- 11110002 (12010);
- 1111100002 (49610).
More formally, the number is beautiful iff there exists some positive integer k such that the number is equal to (2k - 1) * (2k - 1).
Luba has got an integer number n, and she wants to find its greatest beautiful divisor. Help her to find it!
The only line of input contains one number n (1 ≤ n ≤ 105) — the number Luba has got.
Output one number — the greatest beautiful divisor of Luba's number. It is obvious that the answer always exists.
3
1
992
496
模拟下就可以了啊
#include<stdio.h>
int main()
{
int a2[]={,,,,,,,,,,};
int a[],i,n;
for(i=;i<;i++)
a[i]=(a2[i]-)*a2[i-];
scanf("%d",&n);
for(i=;i>=;i--)
{
if(n%a[i]==)
{
printf("%d\n",a[i]);
break;
}
}
return ;
}
Educational Codeforces Round 33 (Rated for Div. 2)的更多相关文章
- Educational Codeforces Round 33 (Rated for Div. 2) E. Counting Arrays
题目链接 题意:给你两个数x,yx,yx,y,让你构造一些长为yyy的数列,让这个数列的累乘为xxx,输出方案数. 思路:考虑对xxx进行质因数分解,设某个质因子PiP_iPi的的幂为kkk,则这个 ...
- Educational Codeforces Round 33 (Rated for Div. 2) F. Subtree Minimum Query(主席树合并)
题意 给定一棵 \(n\) 个点的带点权树,以 \(1\) 为根, \(m\) 次询问,每次询问给出两个值 \(p, k\) ,求以下值: \(p\) 的子树中距离 \(p \le k\) 的所有点权 ...
- Educational Codeforces Round 33 (Rated for Div. 2) 题解
A.每个状态只有一种后续转移,判断每次转移是否都合法即可. #include <iostream> #include <cstdio> using namespace std; ...
- Educational Codeforces Round 33 (Rated for Div. 2)A-F
总的来说这套题还是很不错的,让我对主席树有了更深的了解 A:水题,模拟即可 #include<bits/stdc++.h> #define fi first #define se seco ...
- Educational Codeforces Round 33 (Rated for Div. 2) D. Credit Card
D. Credit Card time limit per test 2 seconds memory limit per test 256 megabytes input standard inpu ...
- Educational Codeforces Round 33 (Rated for Div. 2) C. Rumor【并查集+贪心/维护集合最小值】
C. Rumor time limit per test 2 seconds memory limit per test 256 megabytes input standard input outp ...
- Educational Codeforces Round 33 (Rated for Div. 2) B. Beautiful Divisors【进制思维/打表】
B. Beautiful Divisors time limit per test 2 seconds memory limit per test 256 megabytes input standa ...
- Educational Codeforces Round 33 (Rated for Div. 2) A. Chess For Three【模拟/逻辑推理】
A. Chess For Three time limit per test 1 second memory limit per test 256 megabytes input standard i ...
- Educational Codeforces Round 33 (Rated for Div. 2) D题 【贪心:前缀和+后缀最值好题】
D. Credit Card Recenlty Luba got a credit card and started to use it. Let's consider n consecutive d ...
随机推荐
- Java常用函数式接口--Consumer接口使用案例
第一种方式: 第二种方式:
- js对象引用赋值后
a={f:1} b={} b.a=a console.log(b.a) a.b=2 console.log(b.a) a={f:1} b={} b.a=a console.log(b.a) a={b: ...
- Objective-C Composite Objects
We can create subclass within a class cluster that defines a class that embeds within it an object. ...
- Android 检查内存溢出
工具网址:https://github.com/square/leakcanary 中文版说明地址:http://www.liaohuqiu.net/cn/posts/leak-canary-read ...
- mac ssd开启trim模式
开启方法 sudo trimforce enable
- 简单明了理解Java移位运算符
无须多言: @Test public void intro() { assertThat("应该相等", -1 >> 1, equalTo(-1)); assertTh ...
- (六)使用Docker镜像(下)
1. 创建镜像 创建镜像的方法有三种: 基于已有镜像的容器创建 基于本地模板导入 基于Dockerfile创建 1.1 基于已有镜像的容器创建 该方法主要是使用docker commit命令,其格式 ...
- Kruskal与Prim
一.最小生成树 在无向图中,连通且不含圈的图称为树(Tree).给定无向图G=(V,E),连接G中所有点,且边集是E的子集的树称为G的生成树(Spanning Tree),而权值最小的生成树称为最小生 ...
- 由DAG到背包问题——记忆化搜索和递推两种解法
一.问题描述 物品无限的背包问题:有n种物品,每种均有无穷多个.第 i 种物品的体积为Vi,重量为Wi.选一些物品装到一个容量为 C 的背包中,求使得背包内物品总体积不超过C的前提下重量的最大值.1≤ ...
- nginx的web基础
基于nginx的web部署 [root@nginx ~]# cd /data/web/ client_body_temp/ conf/ fastcgi_temp/ html/ logs/ proxy_ ...