codechef Jewels and Stones 题解
来源:互联网 发布:建国大业 知乎 编辑:程序博客网 时间:2024/06/06 10:42
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
查找字符串的问题。
这里一定要熟悉hash表的运用。经常考的。
还有要懂得判断输入结束的符号 - EOF
#pragma once#include <stdio.h>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;}
- codechef Jewels and Stones 题解
- 【CodeChef】 Chef and Stones
- CF101E Candies and Stones题解
- codechef Ciel and Receipt题解
- codechef Johnny and the Beanstalk 题解
- codechef Little Elephant and Permutations题解
- codechef The Ball And Cups题解
- codechef Row and Column Operations 题解
- codechef Little Elephant and Bombs题解
- codechef Chef and The Right Triangles 题解
- codechef Turbo Sort 题解
- codechef Ambiguous Permutations 题解
- codechef Prime Palindromes 题解
- Codechef Nuclear Reactors 题解
- codechef Cleaning Up 题解
- codechef Permutation Cycles 题解
- codechef Birthday Candles 题解
- codechef Cutting Recipes题解
- hdu2844多重背包简单应用
- nyoj214
- 【Spring】几种RPC模型的使用与比较——Hessian/Burlap
- 编译时控制台报出“error: Apostrophe not preceded by \ ”
- 消息中心 NSNotificationCenter
- codechef Jewels and Stones 题解
- Schema
- 线性表-串:KMP模式匹配算法
- c语言之良好的编程习惯(二)
- 发送手机短信获取验证码功能
- 内核漏洞学习
- 图解天羽翼荣誉与 问问他鲐鯣鱼哦人一日游尔特让他
- 移动互联网,API的战争
- 局部特征——Harris角点