Codechef Jewels and Stones

Source: Internet
Author: User

 

Soma is a fashionable girl. she absolutely loves shiny stones that she can put on as jewellery accessories. she has been collecting stones since her childhood-now she has become really good with identifying which ones are fake and which ones are not. her King requested for her help in mining precious stones, so she has told him which all stones are jewels and which are not. given her description, your task is to count the number of jewel stones.

More formally, you're given a string J composed of latin characters where each character is a jewel. you're also given a string S composed of latin characters where each character is a mined stone. you have to find out how many characters of S are in J as well.

Input

First line contains an integer T denoting the number of test cases. then follow T test cases. each test case consists of two lines, each of which contains a string composed of English lower case and upper characters. first of these is the jewel string J and the second one is stone string S. you can assume that 1 <= T <= 100, 1 <= | J |, | S | <= 100

Output

Output for each test case, a single integer, the number of jewels mined.

Example
Input:4abcabcdefaAabAZaaaawhatnoneOutput:3210

Query string problems.

You must be familiar with the use of hash tables. Frequent tests.

You also need to know the end symbol of the Input-EOF

 

 

#pragma once#include 
 
  class JewelsandStones{public:JewelsandStones(){int T = 0;scanf("%d\n", &T);while (T--){bool J[256] = {false};char c;while ((c = getchar()) != '\n' && c != EOF){J[c] = true;}int ans = 0;while ((c = getchar()) != '\n' && c != EOF){if (J[c]) ans++;}printf("%d\n", ans);}}};int jewelsandStones(){JewelsandStones jewel;return 0;}
 


 

 

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.