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 Description
As the 2010 World Expo hosted by Shanghai is coming, CC is very honorable to be a volunteer of such an international pageant. His job is to guide the foreign visitors. Although he has a strong desire to be an excellent volunteer, the lack of English 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 two countries’ names have the same length and there are more than 2 same letters in the same position of each word, CC cannot distinguish them. For example: Albania and AlgerIa have the same length 7, and their first, second, sixth and seventh letters are same. So CC can’t distinguish them.
Now he has received a name list of countries, please tell him how many words he cannot distinguish. Note that comparisons between letters are case-insensitive.
 

 

Input
There are multiple test cases.
Each case begins with an integer n (0 < n < 100) 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 will not exceed 20.
You can assume that no name will show up twice in the list.
 

 

Output
For each case, output the number of hard names in CC’s list.
 

 

Sample Input
3 Denmark GERMANY China 4 Aaaa aBaa cBaa cBad
 

 

Sample Output
2 4
 
 
#include <cstdio>
#include <cstring>
char str[101][21];
int vis[101];
int main(){
    int t;
    while(scanf("%d", &t)!= EOF){
        int sum = 0;
        memset(vis, 0, sizeof(vis));
        for(int i = 0; i < t; i++){
                scanf("%s", str[i]);
                for(int k = 0; k < strlen(str[i]); k++)
                    if(str[i][k] >= 'A' && str[i][k] <= 'Z')
                        str[i][k] = str[i][k] + 32;
            }
        for(int i = 0; i < t; i++){
            int G = 0;
            for(int j = 0; j < t; j++){
                int cnt = 0;
                int a = strlen(str[i]);
                int b = strlen(str[j]);
                if(a == b){
                        for(int k = 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(int i = 0; i < t; i++){
            if(vis[i])
                sum++;
        }
            printf("%d\n", sum); 
    } 
    return 0;
}

 

 

The Magic Tower

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


Problem Description
Like most of the RPG (role play game), “The Magic Tower” is a game about how a warrior saves the princess.
After killing lots of monsters, the warrior has 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 you to tell him if he can save the princess.
 

Input
There are several test cases.
For each case, the first line is a character, “W” or “B”, indicating that who begins to attack first, ”W” for warrior and ”B” for boss. They attack each other in turn.
The second line contains three integers, W_HP, W_ATK and W_DEF. (1<=W_HP<=10000, 0<=W_ATK, W_DEF<=65535), indicating 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<=B_ATK, B_DEF<=65535), indicating 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.
 

Output
For each case, if boss’s HP first turns to be 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 Input
W 100 1000 900 100 1000 900 B 100 1000 900 100 1000 900
 

Sample Output
Warrior wins Warrior loses
 
//相死, 攻击和护盾是定值, 用数组!!!!!
 
#include <cstdio>
int main(){
    char ch[10];
    while(scanf("%s", ch)){   /*************************/
        int a, 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;
}

 

 
 
posted on 2015-12-26 16:12  cleverbiger  阅读(195)  评论(0编辑  收藏  举报