The country List

Source: Internet
Author: User

The country List

Time limit:2000/1000 MS (java/others) Memory limit:32768/32768 K (java/others)
Total submission (s): 0 Accepted Submission (s): 0


Problem Descriptionas the World Expo hosted by Shanghai are coming, CC is very honorable to BES a volunteer of such an International pageant. The foreign visitors. Although he has a strong desire to is an excellent volunteer, the lack of 中文版 makes him annoyed for a long time.
Some countries ' names look so similar that he can ' t distinguish them. Such As:albania and Algeria. If the countries ' names has the same length and there is more than 2 same letters in the same position of each word, CC Cannot distinguish them. For Example:albania and AlgerIa has the same length 7, and their first, second, sixth and seventh letters are same. So CC can ' t distinguish them.
Now he have received a name list of countries, please tell him how many words he cannot distinguish. Note that comparisons between letters is case-insensitive.

Inputthere is multiple test cases.
Each case begins with a integer n (0 < n <) indicating the number of countries in the list.
The next n lines each contain a country ' s name consisted by ' a ' ~ ' Z ' or ' a ' ~ ' Z '.
Length of each word would not exceed 20.
You can assume that no name would show up twice in the list.

Outputfor each case, output the number of hard names in CC ' s list.

Sample Input3denmarkgermanychina4aaaaabaacbaacbad

Sample Output24
#include <cstdio>#include<cstring>Charstr[101][ +];intvis[101];intMain () {intT;  while(SCANF ("%d", &t)! =EOF) {        intsum =0; memset (Vis,0,sizeof(VIS));  for(inti =0; I < T; i++) {scanf ("%s", Str[i]);  for(intK =0; K < strlen (Str[i]); k++)                    if(Str[i][k] >='A'&& Str[i][k] <='Z') Str[i][k]= Str[i][k] + +; }         for(inti =0; I < T; i++){            intG =0;  for(intj =0; J < T; J + +){                intCNT =0; intA =strlen (Str[i]); intb =strlen (Str[j]); if(A = =b) {                         for(intK =0, F =0; F < b; f++, k++)                            if(Str[i][k] = =str[j][f]) CNT++; if(CNT >2&& cnt! =a) G++; }                if(G) Break; }            if(G) vis[i]=1; }         for(inti =0; I < T; i++){            if(vis[i]) sum++; } printf ("%d\n", sum); }     return 0;}

The Magic TowerTime limit:2000/1000 MS (java/others) Memory limit:32768/32768 K (java/others)
Total submission (s): 0 Accepted Submission (s): 0


Problem Descriptionlike Most of the RPG (role play game), ' The Magic Tower ' is a game on how a warrior saves the Prince Ss.
After killing lots of monsters, the warrior have climbed up the top of the Magic Tower. There is a boss in front of him. The warrior must kill the boss to save the princess.
Now, the warrior wants-to-tell him if he can save the princess.
Inputthere is several test cases.
For each case, the first line was a character, "W" or "B", indicating that who begins to attack first, "W" for Warrior and "B" for boss. They attack each and turn.
The second line contains three integers, w_hp, w_atk and W_def. (1<=w_hp<=10000, 0&LT;=W_ATK, w_def<=65535), Indi Cating Warrior ' s life point, attack value and defense value.
The third line contains three integers, b_hp, b_atk and B_def. (1<=b_hp<=10000, 0&LT;=B_ATK, b_def<=65535), Indic Ating boss's life point, attack value and defense value.

Note:warrior can make a damage of (w_atk-b_def) to Boss if (w_atk-b_def) bigger than zero, otherwise no damage. Also, boss can make a damage of (b_atk-w_def) to Warrior if (b_atk-w_def) bigger than zero, otherwise no damage.
Outputfor each case, if boss's HP first turns to being smaller or equal than zero, please print "Warrior wins". Otherwise, please print "Warrior loses". If Warrior cannot kill the boss forever, please also print "Warrior loses".
Sample InputW100 900100 900b100 1000 900100 1000 900
Sample Outputwarrior Winswarrior loses//die, attacks and shields are fixed values, with arrays!!!!!
#include <cstdio>intMain () {Charch[Ten];  while(SCANF ("%s", CH)) {   /*************************/        intA, B, C, D, E, F; scanf ("%d%d%d%d%d%d", &a, &b, &c, &d, &e, &f); if(B-f <=0&& e-c <=0) {printf ("Warrior loses\n"); Continue; }        if(ch = ='W'){             while(1) {D-= B-F; if(d <=0)                     Break; A-= e-C; if(A <=0)                     Break; }        }        Else{                 while(1) {a-= e-C; if(A <=0)                     Break; D-= B-F; if(d <=0)                     Break; }        }        if(d <=0) printf ("Warrior wins\n"); if(A <=0) printf ("Warrior loses\n"); }    return 0;}

The country List

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.