当前位置:网站首页>【暑期每日一题】洛谷 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;
}
}
} 边栏推荐
- MySQL - multi table query
- 请问flink支持sqlServer数据库么?获取sqlServer数据库的变化
- Interface test actual project 03: execute test cases
- Description of rollingfileappender attribute in logback
- logback日志级别简介说明
- Thinkphp6 realizes database backup
- Fillder use
- Gin service exit
- Operator3 - design an operator
- 我想问一下,我flink作业是以upsert-kafka的方式写入数据的,但是我在mysql里面去更
猜你喜欢

JS chicken laying eggs and egg laying chickens. Who appeared earlier, object or function? Is function an instance of function?

Why does ETL often become ELT or even let?

MySQL如何把行转换为列?

Use vscode to configure Mysql to realize connection, query, and other functions

Spingboot integrates the quartz framework to realize dynamic scheduled tasks (support real-time addition, deletion, modification and query tasks)
Scala 高阶(九):Scala中的模式匹配

1-后台项目搭建

JS 鸡生蛋与蛋生鸡问题,Object与Function究竟谁出现的更早?Function算不算Function的实例?

Practice of online problem feedback module (XVII): realize the online download function of excel template

QT基础第二天(2)qt基础部件:按钮类,布局类,输出类,输入类,容器等个别举例
随机推荐
CMOS芯片制造全工艺流程
WPF interface layout must know basis
Vagrant box cluster processing
BeanUtils.setProperty()
Meta configuration item of route
20-40k | mecarmand 3D vision algorithm / software / Product Manager Recruitment
QT topic: basic components (button class, layout class, output class, input class, container class)
电子元器件贸易企业如何借助ERP系统,解决仓库管理难题?
09 bloom filter
Leetcode 209. subarray with the smallest length (2022.07.28)
WPF simple login page completion case
QT basic day 2 (2) QT basic components: button class, layout class, output class, input class, container and other individual examples
Synchronous / asynchronous, blocking / non blocking and IO
第7节-程序的编译(预处理操作)+链接
彻底搞懂kubernetes调度框架与插件
How much data can a single MySQL table store at most?
How to establish EDI connection with Scania in Scania?
Gin service exit
js中break与continue和return关键字
以太网接口介绍