zoj 2947 Abbreviation
Abbreviation
Time Limit: 2 Seconds Memory Limit: 65536 KB
When a Little White meets another Little White:
Little White A: (Surprised) !
Little White B: ?
Little White A: You Little White know "SHDC"? So unbelievable!
Little White B: You are little white! Little white is you! What is "SHDC" you are talking about?
Little White A: Wait... I mean "Super Hard-disc Drive Cooler".
Little White B: I mean "Spade Heart Diamond Club"... Duck talks with chicken -_-//
Little White A: Duck... chicken... faint!
------quote from qmd of Spade6 in CC98 forum.
Sometimes, we write the abbreviation of a name. For example IBM is the abbreviation for International Business Machines. A name usually consists of one or more words. A word begins with a capital letter ('A' - 'Z') and followed by zero or more lower-case letters ('a' - 'z'). The abbreviation for a name is the word that consists of all the first letters of the words.
Now, you are given two names and asked to decide whether their abbreviations are the same.
Input
Standard input will contain multiple test cases. The first line of the input is a single integer T which is the number of test cases. And it will be followed by T consecutive test cases.
There are four lines for each case.
The first line contains an integer N (1 <= N <= 5), indicating the number of words in the first name.
The second line shows the first name.
The third line contains an integer M (1 <= M <= 5), indicating the number of words in the second name.
The fourth line shows the second name.
Each name consists of several words separated by space. Length for every word is less than 10. The first letter for each word is always capital and the rest ones are lower-case.
Output
Results should be directed to standard output. The output of each test case should be a single line. If two names' abbreviations are the same, output "SAME", otherwise output "DIFFERENT".
Sample Input
3
4
Super Harddisc Drive Cooler
4
Spade Heart Diamond Club
3
Shen Guang Hao
3
Shuai Ge Hao
3
Cai Piao Ge
4
C P C S
Sample Output
SAME
SAME
DIFFERENT
#include <iostream>
#include <string>
#include <cstdio>
using namespace std;
int main(){
int t;
cin >> t;
while(t--){
string str1 = "", str2 = "", temp;
int n, m;
cin >> n;
while(n--){
cin >> temp;
str1 += temp[];
}
cin >> m;
while(m--){
cin >> temp;
str2 += temp[];
}
if(str1.compare(str2) == )
printf("SAME\n");
else
printf("DIFFERENT\n");
}
//system("pause");
return ;
}
zoj 2947 Abbreviation的更多相关文章
- ZOJ People Counting
第十三届浙江省大学生程序设计竞赛 I 题, 一道模拟题. ZOJ 3944http://www.icpc.moe/onlinejudge/showProblem.do?problemCode=394 ...
- [LeetCode] Minimum Unique Word Abbreviation 最短的独一无二的单词缩写
A string such as "word" contains the following abbreviations: ["word", "1or ...
- [LeetCode] Valid Word Abbreviation 验证单词缩写
Given a non-empty string s and an abbreviation abbr, return whether the string matches with the give ...
- [LeetCode] Unique Word Abbreviation 独特的单词缩写
An abbreviation of a word follows the form <first letter><number><last letter>. Be ...
- ZOJ 3686 A Simple Tree Problem
A Simple Tree Problem Time Limit: 3 Seconds Memory Limit: 65536 KB Given a rooted tree, each no ...
- ZOJ Problem Set - 1394 Polar Explorer
这道题目还是简单的,但是自己WA了好几次,总结下: 1.对输入的总结,加上上次ZOJ Problem Set - 1334 Basically Speaking ac代码及总结这道题目的总结 题目要求 ...
- ZOJ Problem Set - 1392 The Hardest Problem Ever
放了一个长长的暑假,可能是这辈子最后一个这么长的暑假了吧,呵呵...今天来实验室了,先找了zoj上面简单的题目练练手直接贴代码了,不解释,就是一道简单的密文转换问题: #include <std ...
- ZOJ Problem Set - 1049 I Think I Need a Houseboat
这道题目说白了是一道平面几何的数学问题,重在理解题目的意思: 题目说,弗雷德想买地盖房养老,但是土地每年会被密西西比河淹掉一部分,而且经调查是以半圆形的方式淹没的,每年淹没50平方英里,以初始水岸线为 ...
- ZOJ Problem Set - 1006 Do the Untwist
今天在ZOJ上做了道很简单的题目是关于加密解密问题的,此题的关键点就在于求余的逆运算: 比如假设都是正整数 A=(B-C)%D 则 B - C = D*n + A 其中 A < D 移项 B = ...
随机推荐
- 关于web中的路径
做了许多Demo发现,浏览器解析的路径和服务器解析的路径是不同的.我们知道,路径加上/的时候,表示的是绝对路径的意思,而如果是服务器解析的话,这个/相对的是我们的web应用,即相对于http://19 ...
- Spark网络通信分析
之前分析过spark RPC的基本流程(spark RPC详解),其实无论是RPC还是Spark内部的数据(Block)传输,都依赖更底层的网络通信,本文将对spark的网络通信做一下剖析. 1,概要 ...
- hashlib加密模块详解
1.hash是把任意长度的消息压缩到某一固定长度的数值的函数. hash主要用于安全加密,把一些不同长度的信息转化成杂乱的128位编码里,叫做hash值. hash就是把内容和内容地址之间找到一种映射 ...
- 微信小程序组件解读和分析:一、view(视图容器 )
view组件说明: 视图容器 跟HTML代码中的DIV一样,可以包裹其他的组件,也可以被包裹在其他的组件内部.用起来比较自由随意,没有固定的结构. view组件的用法: 示例项目的wxml ...
- vue-devtools在google浏览器下安装扩展
下载vue-devtools,地址: https://github.com/vuejs/vue-devtools 解压到对应目录,eg: D:\ProgramFiles\vue-devtools-de ...
- Charles Petzold 编程界大师,世界顶级技术作家 《CODE》值得阅读
<CODE>The Hidden Language of Computer Hardware and Software 从书内容的第一页开始就惊叹于作者的耐心和责任心 整本书以两个隔街对窗 ...
- SAP成都研究院安德鲁:自己动手开发一个Chrome Extension
各位好,我叫何金鑫(He Andrew), 团队同事亲切地称呼在下为安德鲁.如果你在附近找到wifi热点名为 「安德鲁森面包房5g」,可能是我就在附近,我们可以去喝杯咖啡,聊聊最近有趣的东西. 鄙人现 ...
- SQLite与MySQL、SQLServer等异构数据库之间的数据同步
SQLite DBSync是开源嵌入式数据库SQLite的数据同步引擎,实现了SQLite与SQLite数据库之间以及SQLite与异构数据库(Oracle.MySQL.SQLServer)之间的增量 ...
- Socket网络编程初探
http://altboy.blog.51cto.com/5440160/1921720 客户端/服务器架构 即C/S架构,其实web服务在某种意义上也算是C/S架构 一个特点是服务器端持续运行对外提 ...
- python基础一 day5 复习
bytes类型默认编码方式是utf-8和gbk,反正不是unicode strn内部的编码方式是Unicode range相当于只有一次,第一次之后相当于一个有序列表.range顾头不 ...