程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> C語言 >> C++ >> 關於C++ >> hdu 2651 Spring festival couplets

hdu 2651 Spring festival couplets

編輯:關於C++

 

Spring festival couplets

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 194 Accepted Submission(s): 82



Problem Description When the spring festival is coming , people always paste spring festival couplets onto the wall.Now dandelion's father has bought several spring festival couplets, he wants to know how many pairs of spring festival couplets can been consisted with these spring festival couplets.As we know ,spring festival couplets are carefully balanced.Such as AABBCCDD can only be matched with AABBCCDD or BBDDEEFF or AABBAABB ...

Input A number n stands for the number of the spring festival couplets.(2≤n≤110000)
Then n lines ,each line contains a string made by capital letters. Such as AABBCCDD,AABBCCD.The length of the string will not exceed 8.
Output For every case ,print the number of pairs can be made by these spring festival couplets.
Sample Input
6
ABCCCDA
LLLMNNO
DEZZZBF
AAABCCD
KKKXPPQ
AAA

Sample Output
4

題意比較明確對對聯,能配對的就配對問可以配多少對,直接用map映射來做,每次看看之前和當前串一樣模式的出現了幾次,相加就可以了,輸入完就統計完了,不會重復。 然而下午比賽的時候,心情不知道為何會那麼煩躁,水題都寫不好,還是泡腳回家洗洗睡吧。
#include 
#include 
#include 
#include 
#include 
#include 
#include
#include 
#
using namespace std;

char s[10];

int main()
{
    int n;
    while(~scanf(%d,&n))
    {
        mapss;
        int ans=0;
        for(int i=0;i

 

 

 

 

 

 

 

 

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved