zoukankan      html  css  js  c++  java
  • 模拟 Coder-Strike 2014

    题目地址: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
    ", 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
    ", s[i]);
    53                 if (i < n - 1)    puts ("RIGHT");
    54             }
    55         }
    56     }
    57 
    58     return 0;
    59 }
    编译人生,运行世界!
  • 相关阅读:
    连接心跳问题
    超时时间已到
    CSS定位属性-position
    AJAX背景技术介绍
    mysql中length字符长度函数使用方法
    mysql常用函数
    php构造函数的继承方法
    属性选择器(通常用在input)
    input标签常用属性
    PHP程序如何debug?
  • 原文地址:https://www.cnblogs.com/Running-Time/p/4385200.html
Copyright © 2011-2022 走看看