The Country List

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;
}
时间: 2024-12-10 03:51:06

The Country List的相关文章

HDU5723 Abandoned country 最小生成树+深搜回溯法

Description An abandoned country has n(n≤100000) villages which are numbered from 1 to n. Since abandoned for a long time, the roads need to be re-built. There are m(m≤1000000) roads to be re-built, the length of each road is wi(wi≤1000000). Guarante

hdu 5723 Abandoned country 最小生成树+子节点统计

Abandoned country Time Limit: 8000/4000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 3006    Accepted Submission(s): 346 Problem Description An abandoned country has n(n≤100000) villages which are numbered from 1

HDU计算机学院大学生程序设计竞赛(2015’12)The Country List

The Country List Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2598    Accepted Submission(s): 615 Problem Description As the 2010 World Expo hosted by Shanghai is coming, CC is very honorable

zoj 3332 Strange Country II

转载请注明出处:http://blog.csdn.net/u012860063 题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3332 Description You want to visit a strange country. There are n cities in the country. Cities are numbered from 1 to n. The unique way to trav

ural 1073. Square Country

1073. Square Country Time limit: 1.0 secondMemory limit: 64 MB There live square people in a square country. Everything in this country is square also. Thus, the Square Parliament has passed a law about a land. According to the law each citizen of th

URAL 1073 Square Country(DP)

题目链接 题意 :这个人要投资地,每块地都是正方形并且边长都是整数,他希望他要买的地尽量的少碎块.每买一块地要付的钱是边长的平方,而且会得到一个一份证书,给你一个钱数,让你求出能得到的证书个数. 思路 :其实就是求x12+x22+--+Xn2中的最小的n. 1 //1073 2 #include <stdio.h> 3 #include <iostream> 4 #include <math.h> 5 6 using namespace std ; 7 8 int a[

ural1097 Square Country 2

Square Country 2 Time limit: 1.0 secondMemory limit: 64 MB The Square Parliament of the Square country (recall the corresponding problem from the USU 2001 personal contest) has decreed that the National Square Park be created. Of course, the Park sho

Strange Country II ( 简单的dfs,但是要注意细节)

Strange Country II You want to visit a strange country. There are n cities in the country. Cities are numbered from 1 to n. The unique way to travel in the country is taking planes. Strangely, in this strange country, for every two cities A and B, th

ural 1073. Square Country 完全背包

点击打开链接 1073. Square Country Time limit: 1.0 second Memory limit: 64 MB There live square people in a square country. Everything in this country is square also. Thus, the Square Parliament has passed a law about a land. According to the law each citiz

Bubble Cup X - Finals [Online Mirror] B. Neural Network country 矩阵快速幂加速转移

B. Neural Network country time limit per test 2 seconds memory limit per test 256 megabytes Due to the recent popularity of the Deep learning new countries are starting to look like Neural Networks. That is, the countries are being built deep with ma