Codeforces 908A New Year and Counting Cards

浏览: 29 发布日期: 2017-12-30 分类: c

New Year and Counting Cards

time limit per test:1 second
memory limit per test:256 megabytes
input:standard input
output:standard output

Problem Description

Your friend has n cards.

You know that each card has a lowercase English letter on one side and a digit on the other.

Currently, your friend has laid out the cards on a table so only one side of each card is visible.

You would like to know if the following statement is true for cards that your friend owns: "If a card has a vowel on one side, then it has an even digit on the other side." More specifically, a vowel is one of 'a', 'e', 'i', 'o' or 'u', and even digit is one of '0', '2', '4', '6' or '8'.

For example, if a card has 'a' on one side, and '6' on the other side, then this statement is true for it. Also, the statement is true, for example, for a card with 'b' and '4', and for a card with 'b' and '3' (since the letter is not a vowel). The statement is false, for example, for card with 'e' and '5'. You are interested if the statement is true for all cards. In particular, if no card has a vowel, the statement is true.

To determine this, you can flip over some cards to reveal the other side. You would like to know what is the minimum number of cards you need to flip in the worst case in order to verify that the statement is true.

Input

The first and only line of input will contain a string s (1 ≤ |s| ≤ 50), denoting the sides of the cards that you can see on the table currently. Each character of s is either a lowercase English letter or a digit.

Output

Print a single integer, the minimum number of cards you must turn over to verify your claim.

Sample Input

ee
z
0ay1

Sample Output

2
0
2

Hint

In the first sample, we must turn over both cards. Note that even though both cards have the same letter, they could possibly have different numbers on the other side.

In the second sample, we don't need to turn over any cards. The statement is vacuously true, since you know your friend has no cards with a vowel on them.

In the third sample, we need to flip the second and fourth cards.


http://codeforces.com/contest...

Accepted Code

#include "stdio.h"

int main()
{
    char str[100];
    while (scanf_s("%s", &str, 100) != EOF)
    {
        int count = 0;
        for (int i = 0; str[i] != '\0'; i++) {
            if (str[i] == 'a' || str[i] == 'e' || str[i] == 'i' || str[i] == 'o' || str[i] == 'u')
                count++;
            else if (str[i] >= '0' && str[i] <= '9' && (str[i] - '0') % 2)
                count++;
        }
        printf("%d\n", count);
    }
    return 0;
}

Notes

题意:
统计字符串中元音字母和奇数的出现次数。

//-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
//
// 作者:龙威昊
// 完成时间:2017/12/30
//
//-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

返回顶部