zoukankan      html  css  js  c++  java
  • ZOJ 3207 80ers' Memory (F)

    80ers' Memory

    Time Limit: 1 Second      Memory Limit: 32768 KB

    I guess most of us are so called 80ers, which means that we were born in the 1980's. This group of people shared a lot of common memories. For example, the Saint Seiya, the YoYo ball, the Super Mario, and so on. Do you still remember these?

    Input

    There will be ONLY ONE test case.

    The test case begins with a positive integer N, (N < 100).
    Then there will be N lines each containing a single word describing a keyword of the typical 80ers' memories. Each word consists of letters, [a-zA-Z], numbers, [0-9], and the underline, '_'. The length of each word would be no more than 20.
    Then one line follows with a positive integer K, (K < 100).
    The last part of the test case will be K lines. The i-th line contains the keywords given by the i-th person and starts with a positive integer Ni. Then there will be Ni words separated by white spaces. Each of these words has no more than 20 characters.
    All the words are case sensitive.

    Output

    For each of these K people, you are asked to count the number of typical 80ers' keywords on his/her list and output it in a single line.

    Sample Input

    4
    Saint_Seiya
    YoYo_ball
    Super_Mario
    HuLuWa
    3
    2 Saint_Seiya TiaoFangZi
    1 KTV
    3 HuLuWa YOYO_BALL YoYo_ball
    

    Sample Output

    1
    0
    2

    水题
     1 #include <iostream>
     2 #include <cstring>
     3 #include <cstdio>
     4 #include <string>
     5 using namespace std;
     6 #define maxn 105
     7 int N, K;
     8 string s[maxn];
     9 struct Node{
    10     int n;
    11     string word[maxn];
    12 }node[maxn];
    13 int main(){
    14     scanf("%d", &N);
    15     for(int i = 1; i <= N; i++) cin>>s[i];
    16     scanf("%d", &K);
    17     for(int i = 1; i <= K; i++){
    18         scanf("%d", &node[i].n);
    19         for(int j = 1; j <= node[i].n; j++) cin>>node[i].word[j];
    20     }
    21     
    22     for(int i = 1; i <= K; i++){
    23         int cnt = 0;
    24         for(int j = 1; j <= node[i].n; j++){
    25             for(int k = 1; k <= N; k++){
    26                 if(node[i].word[j] == s[k]){
    27                     cnt++;break;
    28                 }
    29             }
    30         }
    31         printf("%d
    ", cnt);
    32     }
    33     
    34     return 0;
    35 }
  • 相关阅读:
    Java 得到指定时间加半个小时之后得时间
    MySQL查询point类型类型的坐标,返回经度纬度
    MySQL通过实体经纬度字段插入数据库point类型的经纬度字段
    MySQL通过POIN数据类型查询指定范围内数据
    Java 根据两个经纬度,得到两点距离
    mysql通过经纬度查询400公里范围内的小区
    位运算
    Hibernate多对多删除问题的解决
    mysql 中 时间和日期函数
    Struts2数据传输的背后机制:ValueStack(值栈)
  • 原文地址:https://www.cnblogs.com/titicia/p/3917100.html
Copyright © 2011-2022 走看看