当前位置:网站首页>【暑期每日一题】洛谷 P6461 [COCI2006-2007#5] TRIK
【暑期每日一题】洛谷 P6461 [COCI2006-2007#5] TRIK
2022-07-29 07:08:00 【AC_Dragon】
题目链接:P6461 [COCI2006-2007#5] TRIK - 洛谷 | 计算机科学教育新生态 (luogu.com.cn)
题目描述

有三个杯口朝下的杯子,其中有一个小球在最左边的杯子下。
接下来,对这三个杯子进行一系列的换位操作,操作用一个字符串来表示,其中 A B C 分别对应了上图所示的三种换位方式。
你需要找出最终小球在哪个杯子下面。
输入格式
输入一行一个字符串,表示操作的顺序,保证操作数不超过 50 ,且每个字母都为 A B C 中的一种,无空格。
输出格式
输出一行一个整数:
- 如果球在左边的杯子下:输出 1;
- 如果球在中间的杯子下:输出 2;
- 如果球在右边的杯子下:输出 3。
样例 #1
样例输入 #1
AB样例输出 #1
3样例 #2
样例输入 #2
CBABCACCC样例输出 #2
1提示
说明
题目译自 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;
}
}
} 边栏推荐
- Ethernet interface introduction
- CMOS芯片制造全工艺流程
- Reflect reflect
- BeanUtils.setProperty()
- Spark Learning Notes (VII) -- spark core core programming - RDD serialization / dependency / persistence / partition / accumulator / broadcast variables
- Homebrew brew update doesn't respond for a long time (or stuck in updating homebrew...)
- 同步/异步、阻塞/非阻塞 与 IO
- 能在SQL 语句中 指定 内存参数吗?
- logback简介及引入方法
- 力扣(LeetCode)209. 长度最小的子数组(2022.07.28)
猜你喜欢

Operator3-设计一个operator

Spark Learning Notes (VII) -- spark core core programming - RDD serialization / dependency / persistence / partition / accumulator / broadcast variables

gcc/g++的使用

Spingboot integrates the quartz framework to realize dynamic scheduled tasks (support real-time addition, deletion, modification and query tasks)

Interface test actual project 03: execute test cases

JS day 4 process control (if statement and switch statement)
Scala 高阶(九):Scala中的模式匹配

MySQL uses the client and select methods to view the summary of blob type fields

Vite3.0 has been released, can you still roll it (list of new features)

一篇长文---深入理解synchronized
随机推荐
3-全局异常处理
jdbc入门
电子元器件贸易企业如何借助ERP系统,解决仓库管理难题?
Homebrew brew update 长时间没反应(或卡在 Updating Homebrew...)
美智光电IPO被终止:年营收9.26亿 何享健为实控人
Comparison of advantages between can & canfd integrated test analysis software lkmaster and PCA Explorer 6 analysis software
Remote invocation of microservices
logback appender简介说明
Fillder use
gcc/g++的使用
使用自定义注解校验list的大小
Gin routing, parameters, output
@RequestMapping 用法详解
反射reflect
[Charles' daily problems] when you open Charles, you can't use nails
Vagrant box cluster processing
logback简介及引入方法
Docker最新超详细教程——Docker创建运行MySQL并挂载
CDC source can quit after reading MySQL snapshot split
Operator3 - design an operator