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 = ...
随机推荐
- .NET Core WebAPI Swagger使用
相对于普通的webapi而言,.net core webapi本身并不具备文档的功能,所以可以借助第三方插件:swagger,使用的话很简单. 步骤一. Nuget Packages安装,使用程序包管 ...
- HashMap的简单实现
基本概念 Map 别名映射表,也叫关联数组,基本思想是它维护的键-值(对)关联,因此可以用键查找值,也有放入键值的操作,下面根据定义自己来实现一个Map,首先应该想到的是数组,因为大多数Java集合类 ...
- CF779B(round 402 div.2 B) Weird Rounding
题意: Polycarp is crazy about round numbers. He especially likes the numbers divisible by 10k. In the ...
- Android Studio3.0 Error:Execution failed for task ':app:javaPreCompileDebug' 错误
Error:Execution failed for task ':app:javaPreCompileDebug'. > Annotation processors must be expli ...
- 下载JSTL方法
第一步:访问 http://www.apache.org/dist/ 第二步:点击jakarta
- Win10 系统安装Sql Server2008 R2 数据库遇到的问题及解决办法总结!
1.开始安装时,提示要先安装 “.NET Framework 3.5(包括.NET 2.0和3.0)”,之前已经下载好.NET Framework 3.5 sp1,安装时还是提示要先安装 “.NET ...
- HDU 5416 CRB and Tree (技巧)
题意:给一棵n个节点的树(无向边),有q个询问,每个询问有一个值s,问有多少点对(u,v)的xor和为s? 注意:(u,v)和(v,u)只算一次.而且u=v也是合法的. 思路:任意点对之间的路径肯定经 ...
- SAP云平台架构概述
在我们开始SAP云平台的架构之旅之前,让我们先看看SAP已经发布的一些其他云产品.这些云产品方案可以分为公有云和私有云两种. SAP公有云解决方案见下图最右侧,比较著名的有SAP SuccessFac ...
- javaee 第八周作业
hashcode()和equals()的作用.区别.联系 先来试想一个场景,如果你想查找一个集合中是否包含某个对象,那么程序应该怎么写呢?通常的做法是逐一取出每个元素与要查找的对象一一比较,当发现两者 ...
- iOS 如何使用TabbarController
xcode中给我内置很多app模版,不过很多时候我们需要更加灵活的初始化项目.下面我就简单介绍一下,如何从0开始制作一个tabbar app. 创建个项目,由于我们从头开始写程序,因此理论上对模版没有 ...