A Tale from the Dark Side of The Moon

2023-11-08 11:33
文章标签 dark side tale moon

本文主要是介绍A Tale from the Dark Side of The Moon,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

A Tale from the Dark Side of The Moon

Time Limit: 1000MS Memory limit: 65536K

题目描述

Us: So why don’t you just recompile the program Us: What about "ddd" and "dddd"? How does it on the new hardware? behave then?
Them: We cannot. We lost the source code. Them: Where in English will you find a "dddd" or even a "ddd"? Haven’t you been listening?
Us: How typical! What does the program do? Do you have any documentation?
Them: The manual page does mention something about the documentation in the source code.
Us: A manual page is good. What does it say?
Them: Just one line: “See the source code for more information.”
Us: Argh! What do you know about the program?
Them: Well, it seems to be taking simple text, similar to that found in an English dictionary, and printing it after some modification.
Us: What kind of modification?
Them: It removes any character that is not a lowercase letter. But not white spaces. White spaces are preserved as seen in the input.
Us: Do you have a sample input/output?
Them: Plenty. Here’s one. (see next page.)
Us: This is rather small! Did you try it on anything
bigger?
Us: Oops. We’ll pay more attention. Anything else?
Another one of them: There is also the "vv" thingy.
Us: What about "vv"?
Them: Every "vv" is replaced with a "m".Yet another one of them: No, wait! That was a printer problem. it had nothing to do with the program.
Remember?
Them: Oh, that’s right.thingy. Forget about the "vv"
Us: What about the "dd" thingy? Was that just a printer problem too?
Them: No. That was the program.
Us: What else?
Them: One last thing.every "ei" with "ie".It seems to be replacing
Us: Every one of them?
Them: Except if it comes right after "c" then it remains as is.
Them: It works on any text as long as the lines are Them: No, we just remembered one more thing: It less then eighty characters wide. It doesn’t seem replaces the sequence "pink" with "floyd" any to mind working on lengthy documents. But it where in the text.does terminate once it sees the sequence "EOF" (without the double quotes.) 
One of them: Don’t forget to tell them about the Us: What?! Who wrote this program? Why do you "dd" thingy. need it in the first place?
Us: : What "dd" thingy?
Them: We think it will increase our chances of going to Banff in April 2008 if we get it right.
Them: Whenever it sees a pair of small letter "d",one right after the other, it replaces them with "p".
Us: Makes sense. That’s all, right?
Us: Yeah! Right.
Us: Why?
Them: Who knows? It just does that!

输入

输出

示例输入

unpinked is an 8 letter word. Honest!
vv is ok, d123d is ok, 123dd is not
i received mail from        liechtenstein..  ...adding means to imitat.#$!%%$e
EOF

示例输出

unfloyded is an  letter word onest
vv is ok dd is ok p is not
i received mail from        liechtenstienaping means to imitate


代码:

#include <iostream>
#include <string>
using namespace std;
int main()
{while(true){string s1;string s2 = "";getline(cin, s1);int l = s1.length();bool flag = true;for (int i = 0; i < l; i++){char c = s1.at(i);if(i < l-1 && c == 'd' && s1.at(i+1) == 'd'){s2 += 'p';i++;}else if(i < l-1 && c == 'e' && s1.at(i+1) == 'i' && (i==0 || s1.at(i-1) != 'c')){s2 += "ie";i++;}else if(i < l-3 && c == 'p' && s1.at(i+1) == 'i' && s1.at(i+2) == 'n' && s1.at(i+3) == 'k'){s2 += "floyd";i += 3;}else if( i< l-2 && c== 'E' && s1.at(i+1) == 'O' && s1.at(i+2) == 'F'){flag = false;break;}else if(c >= 'a' && c <= 'z' || c== ' ')s2 += c;}cout<<s2<<endl;if (flag == false)break;}return 0;
}


这篇关于A Tale from the Dark Side of The Moon的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/369577

相关文章

Ajax, SPA, Client-Side VS Server-Side code difference

What is Ajax: http://www.seguetech.com/what-is-ajax-and-where-is-it-used-in-technology/ Single Page Application:  http://www.seguetech.com/what-is-a-single-page-application/ Client-Side vs. Server

mac eclipse Dark 暗黑主题设置以及git字体设置

Preferences -> General -> Appearance  选择 Dark

WHAT - 通过 react-use 源码学习 React(Side-effects 篇)

目录 一、官方介绍1. Sensors2. UI3. Animations4. Side-Effects5. Lifecycles6. State7. Miscellaneous 二、源码学习示例:n. xx - yySide-effects - useAsync, useAsyncFn, and useAsyncRetryuseAsyncuseAsyncFnuseAsyncRetry

vue3+el-tale封装(编辑、删除、查看详情按钮一起封装)

// 封装源码(子组件)<template><el-table :data="tableData" style="width: 100%"><el-table-columnv-for="(column, index) in tableDataHeader":label="column.label":key="index":prop="column.prop":width="column.widt

uva5318 The Goddess Of The Moon dp+矩阵快速幂

dp[i][j]表示前i个以j结尾的方案数,可以由一系列dp[i-1][k]相加得出。类似求斐波那契数的第n项,由于非常大,用矩阵快速幂转移。 import java.io.*;import java.math.BigDecimal;import java.util.ArrayList;import java.util.Arrays;import java.util.Comparat

解决报错“RuntimeError: CUDA error: device-side assert triggered ”

这是一个比较通用的错误,通常发生在以下几种情况下: 索引超出范围:在某些情况下,操作涉及的张量索引超出了允许的范围。例如,使用 index_select 或 gather 时,索引可能超出张量的范围。非法操作:例如对负数取对数、零除法,或对概率分布应用 log 函数时存在无效值(例如 0)。数据类型或维度不匹配:操作的输入张量可能在维度或数据类型上不匹配,这会触发设备端的断言。类别标签非法:如果

Binary Tree Right Side View

Notes:站在右边看,即层次遍历,只保存每一层的最后一个值! /*** Definition for binary tree* public class TreeNode {* int val;* TreeNode left;* TreeNode right;* TreeNode(int x) { val = x; }* }*/public class S

(自动深色模式)Windows 10 Auto Dark Mode

需求 想让Win10像手机那样,到点自动切换深色模式/浅色模式 解决方案 Windows 10 Auto Dark Mode – Win10 自动深色模式 GitHub:https://github.com/Armin2208/Windows-Auto-Night-Mode/

Binary Tree Right Side View问题及解法

问题描述: Given a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom. 示例: Given the following binary tree, 1

uva 825 Walking on the Safe Side(动态规划:记忆化搜索)

题目的输入太蛋疼了... 题目本身倒是不难 代码如下: #include <cstdio>#include <cstring>#include <iostream>#include <algorithm>#define MAXN 1010using namespace std;char str[MAXN];int a[MAXN][MAXN], dp[MAXN][MAXN];i