Codeforces Round #426 A

The Useless Toy

题意:如下图字符的变换

现在给你初始的字符和旋转n次的字符,问你,它是顺时针还是逆时针或者是其他

思路:4为循环节,先保存好顺时针和逆时针的字符顺序,然后判断初始的时候字符在第几个,再让初始字符回到第0的位置(关于循环节的问题一般直接模循环节然后从0开始标序号)

AC代码:

#include "iostream"
#include "string.h"
#include "stack"
#include "queue"
#include "string"
#include "vector"
#include "set"
#include "map"
#include "algorithm"
#include "stdio.h"
#include "math.h"
#pragma comment(linker, "/STACK:102400000,102400000")
#define ll long long
#define bug(x) cout<<x<<" "<<"UUUUU"<<endl;
#define mem(a,x) memset(a,x,sizeof(a))
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define lrt (rt<<1)
#define rrt (rt<<1|1)
using namespace std;
const long long INF = 1e18+1LL;
const int inf = 1e9+1e8;
const int N=1e6+100;
const ll mod=1e9+7;

char s,e,s1[5]=">v<^",s2[5]="^<v>";
int n;
int main(){
    cin>>s>>e>>n;
    int k1=n, k2=n;
    for(int i=0; i<=3; ++i){
        if(s==s1[i]){
            k1+=i;
            break;
        }
    }
    for(int i=0; i<=3; ++i){
        if(s==s2[i]){
            k2+=i;
            break;
        }
    }
    k1%=4, k2%=4;
    if(s1[k1]==e && s2[k2]!=e){
        cout<<"cw\n";
        return 0;
    }
    if(s2[k2]==e && s1[k1]!=e){
        cout<<"ccw\n";
        return 0;
    }
    else cout<<"undefined\n";
    return 0;
}
时间: 2024-10-05 18:15:44

Codeforces Round #426 A的相关文章

Codeforces Round #426 (Div. 2) D. The Bakery(线段树维护dp)

题目链接: Codeforces Round #426 (Div. 2) D. The Bakery 题意: 给你n个数,划分为k段,每段的价值为这一段不同的数的个数,问如何划分,使得价值最大. 题解: 考虑dp[i][j]表示划分为前j个数划分为i段的最大价值,那么这就是一个n*n*k的dp, 考虑转移方程dp[i][j]=max{dp[i][k]+val[k+1][j]},我们用线段树去维护这个max,线段树上每个节点维护的值是dp[i][k]+val[k+1][j],对于每加进来的一个数a

Codeforces Round #426 (Div. 2)A B C题+赛后小结

最近比赛有点多,可是好像每场比赛都是被虐,单纯磨砺心态的作用.最近讲的内容也有点多,即便是点到为止很浅显的版块,刷了专题之后的状态还是~"咦,能做,可是并没有把握能A啊".每场网络赛,我似乎都没用上新学的东西,能用上新学东西的题我A不了...5555555555555555 这场CF,讲真,打的心态爆炸,首先A题无限WA,赛后看下WA的那组数据是输入有一个999999999的样例,死骗子,说好的数据是1e9呢,哪能有数据是1e10-1,于是用long long,一下子Accept接收不

Codeforces Round #426 (Div. 2) C. The Meaningless Game (二分 or pow函数)

Slastyona and her loyal dog Pushok are playing a meaningless game that is indeed very interesting. The game consists of multiple rounds. Its rules are very simple: in each round, a natural number k is chosen. Then, the one who says (or barks) it fast

Codeforces Round #426 (Div. 2) (A B C)

A. The Useless Toy Walking through the streets of Marshmallow City, Slastyona have spotted some merchants selling a kind of useless toy which is very popular nowadays – caramel spinner! Wanting to join the craze, she has immediately bought the strang

Codeforces Round #426 (Div. 1) A.The Meaningless Game (二分+数学)

题目链接: http://codeforces.com/problemset/problem/833/A 题意: 给你 \(a\) 和 \(b\),两个人初始化为 \(1\).两个人其中一方乘以 \(k^2\),另一方就乘以 \(k\).问你能不能达到 \((a,b)\) 这个最终状态. 题解: 设 \(X\), \(P\) 表示两个乘积的集合. 那么,显然: \(S^{2}*P=a\) ------ 1 \(S*P^{2}=b\) ------ 2 所以:\(a*b = S^{3}*P^3\)

codeforces round #426 div 2

A: 如果n%2=0或2就是undefined,否则判一下转一下是否能到达状态 #include<bits/stdc++.h> using namespace std; int n; char s[10], t[10]; int main() { scanf("%s%s%d", s, t, &n); if(n % 4 == 0 || n % 4 == 2) { puts("undefined"); return 0; } if((s[0] ==

Codeforces Round #426 (Div. 2)A. The Useless Toy

题意:4个箭头,给出起始箭头,终始箭头,问经历n次,是由顺时针cw得到,还是逆时针cww得到,如果都可以输出undefined 思路:n%4,就是次数了,再两个方向模拟下 1 #include<bits/stdc++.h> 2 using namespace std; 3 typedef long long ll; 4 const int N=1e5+10; 5 6 int a[6]={0,1,2,3,4}; 7 int main(){ 8 int n; 9 char s1[2],s2[2];

Codeforces Round #426 (Div. 2)C. The Meaningless Game

题意:AB两个人,每一轮,其中一人选择一个数字K,那么A就变成A*k*k,B就变成B*K,给出结果,问是否可能 思路:不管多少轮,A*B结果都是某个数的立方,二分 1 #include<bits/stdc++.h> 2 using namespace std; 3 typedef long long ll; 4 const int N=1e5+10,M=1e6+10,inf=1e9+7,MOD=1e9+7; 5 const ll INF=1e18+10,mod=1e9+7; 6 7 8 int

Codeforces Round #426 (Div. 2)B. The Festive Evening

题意:有26个城门,k个守卫,给出每个城门人进入的顺序,只有当这个城门进入的人是最后一个,该城门的守卫才能去别的城门,问是否有个时间段,守卫不够用 思路:记录起始,模拟下 1 #include<bits/stdc++.h> 2 using namespace std; 3 4 int l[30],r[30]; 5 int b[30]; 6 7 int main(){ 8 int n,m; string s; 9 cin>>n>>m; 10 cin>>s; 1