首页 > ACM题库 > HDU-杭电 > hdu 2408 String Equations待解决[解题报告]C++
2014
01-26

hdu 2408 String Equations待解决[解题报告]C++

String Equations

问题描述 :

We all understand equations such as:

3 + 8 = 4 + 7

But what happens if we look at equations with strings instead of numbers? What would addition and equality mean?

Given two strings x and y, we define x + y to be the concatenation of the two strings. We also define x = y to mean that x is an anagram of y. That is, the characters in x can be permuted to form y.

You are given n distinct nonempty strings, each containing at most 10 lowercase characters. You may also assume that at most 10 distinct characters appear in all the strings. You need to determine if you can choose strings to put on both sides of an equation such that the "sums" on each side are "equal" (by our definitions above). You may use each string on either side 0 or more times, but no string may be used on both sides.

输入:

The input consists of a number of cases. Each case starts with a line containing the integer n (2 <= n <= 100). The next n lines contain the n strings. The input is terminated with n = 0.

输出:

The input consists of a number of cases. Each case starts with a line containing the integer n (2 <= n <= 100). The next n lines contain the n strings. The input is terminated with n = 0.

样例输入:

2
hello
world
7
i
am
lord
voldemort
tom
marvolo
riddle
0

样例输出:

no
yes
i L 1
am L 1
lord L 1
voldemort L 1
tom R 1
marvolo R 1
riddle R 1


  1. Hello Web Admin, I noticed that your On-Page SEO is is missing a few factors, for one you do not use all three H tags in your post, also I notice that you are not using bold or italics properly in your SEO optimization. On-Page SEO means more now than ever since the new Google update: Panda. No longer are backlinks and simply pinging or sending out a RSS feed the key to getting Google PageRank or Alexa Rankings, You now NEED On-Page SEO. So what is good On-Page SEO?First your keyword must appear in the title.Then it must appear in the URL.You have to optimize your keyword and make sure that it has a nice keyword density of 3-5% in your article with relevant LSI (Latent Semantic Indexing). Then you should spread all H1,H2,H3 tags in your article.Your Keyword should appear in your first paragraph and in the last sentence of the page. You should have relevant usage of Bold and italics of your keyword.There should be one internal link to a page on your blog and you should have one image with an alt tag that has your keyword….wait there's even more Now what if i told you there was a simple WordPress plugin that does all the On-Page SEO, and automatically for you? That's right AUTOMATICALLY, just watch this 4minute video for more information at.