当前位置:网站首页>[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
AB
Sample output #1
3
Examples #2
The sample input #2
CBABCACCC
Sample output #2
1
Tips
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;
}
}
}
边栏推荐
- 【暑期每日一题】洛谷 P1601 A+B Problem(高精)
- 1-后台项目搭建
- Spingboot integrates the quartz framework to realize dynamic scheduled tasks (support real-time addition, deletion, modification and query tasks)
- @RequestMapping 用法详解
- 能在SQL 语句中 指定 内存参数吗?
- 暑期总结(二)
- Full process flow of CMOS chip manufacturing
- JS chicken laying eggs and egg laying chickens. Who appeared earlier, object or function? Is function an instance of function?
- Scala higher order (IX): pattern matching in Scala
- 【暑期每日一题】洛谷 P6320 [COCI2006-2007#4] SIBICE
猜你喜欢
【暑期每日一题】洛谷 P7760 [COCI2016-2017#5] Tuna
Scala 高阶(九):Scala中的模式匹配
1-后台项目搭建
QT basic day 2 (2) QT basic components: button class, layout class, output class, input class, container and other individual examples
【WPF】通过动态/静态资源实现语言切换
论文阅读 (62):Pointer Networks
QT连接两个qslite数据库报错QSqlQuery::exec: database not open
OA项目之会议通知(查询&是否参会&反馈详情)
Scala 高阶(十):Scala中的异常处理
halcon的安装以及在vs2017中测试,vs2017中dll的配置
随机推荐
JS day 4 process control (if statement and switch statement)
Does Flink support sqlserver databases? Get the changes of SQLSERVER database
在线问题反馈模块实战(十七):实现excel模板在线下载功能
Thoroughly understand kubernetes scheduling framework and plug-ins
stm32 操作W25Q256 W25Q16 spi flash
论文阅读 (62):Pointer Networks
PAT甲级 1154 顶点着色
logback filter过滤器简介说明
WPF simple login page completion case
Female graduate students do "mind mapping" and quarrel with their boyfriend! Netizen: the "king of infighting" in the quarrel
Gin parameter validation
【暑期每日一题】洛谷 P6336 [COCI2007-2008#2] BIJELE
PAT甲级 1146 拓扑顺序
Custom events
gin abort不能阻止后续代码的问题
Homebrew brew update doesn't respond for a long time (or stuck in updating homebrew...)
请问flink支持sqlServer数据库么?获取sqlServer数据库的变化
route的meta配置项
【暑期每日一题】洛谷 P6408 [COCI2008-2009#3] PET
Vue router route cache