当前位置:网站首页>[summer daily question] Luogu p6461 [coci2006-2007 5] trik
[summer daily question] Luogu p6461 [coci2006-2007 5] trik
2022-07-29 07:28:00 【AC_ Dragon】
Topic link :P6461 [COCI2006-2007#5] TRIK - Luogu | New ecology of computer science education (luogu.com.cn)
Title Description

A cup with three cups facing down , There is a small ball under the leftmost Cup .
Next , Perform a series of transposition operations on the three cups , The operation is represented by a string , among A B C They correspond to the three transposition modes shown in the above figure .
You need to find out which cup the final ball is under .
Input format
Enter one string per line , Indicates the order of operations , Ensure that the operands do not exceed 50 , And each letter is A B C One of the , No spaces .
Output format
Output a line of integers :
- If the ball is under the cup on the left : Output 1;
- If the ball is under the middle Cup : Output 2;
- If the ball is under the cup on the right : Output 3.
Examples #1
The sample input #1
ABSample output #1
3Examples #2
The sample input #2
CBABCACCCSample output #2
1Tips
explain
The title is translated from COCI2006-2007 CONTEST #5 T1 TRIK.
AC code:
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
int a[3]={1,0,0};
string x;
cin>>x;
for(auto i:x)
{
switch(i)
{
case 'A':
{
swap(a[0],a[1]);
break;
}
case 'B':
{
swap(a[1],a[2]);
break;
}
case 'C':
{
swap(a[0],a[2]);
break;
}
}
}
for(int i=0;i<3;i++)
{
if(a[i]==1)
{
cout<<i+1;
return 0;
}
}
} 边栏推荐
- Some learning and understanding of vintage analysis
- QT基础第二天(2)qt基础部件:按钮类,布局类,输出类,输入类,容器等个别举例
- QT专题:基础部件(按钮类,布局类,输出类,输入类,容器类)
- 同步/异步、阻塞/非阻塞 与 IO
- Zabbix 其他基础监控项
- 第7节-程序的编译(预处理操作)+链接
- 用户列表 圆形头像并跟随小板块
- JS day 4 process control (if statement and switch statement)
- logback 中FileAppender具有什么功能呢?
- 【暑期每日一题】洛谷 P6500 [COCI2010-2011#3] ZBROJ
猜你喜欢

【MYSQL】-【子查询】
Scala 高阶(九):Scala中的模式匹配

【OpenGL】着色器(Shader)的使用

Thoroughly understand kubernetes scheduling framework and plug-ins

leetcode力扣经典问题——4.寻找两个正序数组的中位数

WPF nested layout case

SEGGER 的硬件异常 分析

2-unified return class dto object

My personal website doesn't allow access to wechat, so I did this

Using C language to skillfully realize the chess game -- Sanzi chess
随机推荐
Introduction to log4j layout
【暑期每日一题】洛谷 P4414 [COCI2006-2007#2] ABC
Interface test actual project 03: execute test cases
How to establish EDI connection with Scania in Scania?
js第四天流程控制(if语句和switch语句)
Gin Middleware
PAT甲级 1154 顶点着色
Thoroughly understand kubernetes scheduling framework and plug-ins
Summary of OCR optical character recognition methods
20-40k | mecarmand 3D vision algorithm / software / Product Manager Recruitment
Scala higher order (10): exception handling in Scala
Using C language to skillfully realize the chess game -- Sanzi chess
5-整合swagger2
时钟树综合(一)
do end用法的妙处
一篇长文---深入理解synchronized
2022-07-28: what is the output of the following go language code? A:AA; B:AB; C:BA; D:BB。 package main import ( “fmt“ ) func main() { f
JS chicken laying eggs and egg laying chickens. Who appeared earlier, object or function? Is function an instance of function?
Life cycle hooks in routing - activated and deactivated
Synchronous / asynchronous, blocking / non blocking and IO