模拟 Coder-Strike 2014 - Round 1 A. Poster
题目地址:http://codeforces.com/problemset/problem/412/A
1 /*
2 模拟:题目没看懂,但操作很简单,从最近的一头(如果不在一端要先移动到一端)往另一头移动,顺便打印内容
3 */
4 #include <cstdio>
5 #include <iostream>
6 #include <algorithm>
7 #include <cmath>
8 #include <cstring>
9 #include <string>
10 #include <map>
11 using namespace std;
12
13 const int MAXN = 100 + 10;
14 const int INF = 0x3f3f3f3f;
15 char s[MAXN];
16
17 int main(void) //Coder-Strike 2014 - Round 1 A. Poster
18 {
19 //freopen ("E.in", "r", stdin);
20
21 int n, k;
22 while (~scanf ("%d%d", &n, &k))
23 {
24 scanf ("%s", &s);
25 int pos; int flag;
26
27 if (k <= (n) / 2)
28 {
29 pos = k - 1; flag = 0;
30 }
31 else
32 {
33 pos = n - k; flag = 1;
34 }
35
36 while (pos--) (flag) ? puts ("RIGHT") : puts ("LEFT");
37
38 if (flag == 1)
39 {
40 for (int i=n-1; i>=0; --i)
41 {
42 printf ("PRINT ");
43 printf ("%c\n", s[i]);
44 if (i > 0) puts ("LEFT");
45 }
46 }
47 else
48 {
49 for (int i=0; i<n; ++i)
50 {
51 printf ("PRINT ");
52 printf ("%c\n", s[i]);
53 if (i < n - 1) puts ("RIGHT");
54 }
55 }
56 }
57
58 return 0;
59 }
编译人生,运行世界!
【推荐】还在用 ECharts 开发大屏?试试这款永久免费的开源 BI 工具!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 对象命名为何需要避免'-er'和'-or'后缀
· SQL Server如何跟踪自动统计信息更新?
· AI与.NET技术实操系列:使用Catalyst进行自然语言处理
· 分享一个我遇到过的“量子力学”级别的BUG。
· Linux系列:如何调试 malloc 的底层源码
· JDK 24 发布,新特性解读!
· C# 中比较实用的关键字,基础高频面试题!
· .NET 10 Preview 2 增强了 Blazor 和.NET MAUI
· Ollama系列05:Ollama API 使用指南
· 为什么AI教师难以实现