URAL - 1786 Sandro's Biography

Time Limit: 1000MS Memory Limit: 65536KB 64bit IO Format: %I64d & %I64u

 Status

Description

Leogius was searching in a library for a book recommended to him by the teacher of theoretical magic. Suddenly he found an ancient chronicle written on several sheets of parchment. Having looked through it, Leogius understood that it described the life and amazing adventures of a lich. Could it be the biography of Lich Sandro that had been lost many centuries ago? If so, the manuscript had to be shown to the Supreme Council of Magicians as soon as possible. But there was one problem: the text contained no mention of the name Sandro. What could be done? The Council might not believe that the chronicle recounted Sandro's life.
Leogius decided to correct the manuscript. He found a magician who was willing to do it. But a good job had to be paid well. The proofreader agreed to replace any letter by any other same-case letter (an uppercase letter by an uppercase letter and a lowercase letter by a lowercase letter) for five gold coins. He also could change the case of any letter for five gold coins. Help Leogius determine the minimal quantity of gold coins he had to pay to make the string “Sandro” appear in the text.

Input

The only line contains the text of the manuscript. It consists of lowercase and uppercase English letters. The number of letters in the text is at least six and at most 200.

Output

Output the minimal quantity of gold coins that must be paid to make the name Sandro appear in the text.

Sample Input

input output
MyNameIsAlexander
20

Notes

In the example the corrector will have to perform four operations after which the line will sequentially take the following form: “MyNameIsAlesander”, “MyNameIsAlesandrr”, “MyNameIsAlesandro”, and “MyNameIsAleSandro”.


枚举就好了。

#include<iostream>
#include<algorithm>
#include<cctype>
using namespace std;
int cost1(char c)
{
	if (c == 'S') return 0;
	if (c == 's'||isupper(c)) return 5;
	return 10;
}
int cost2(char c)
{
	if (c == 'a') return 0;
	if (c == 'A'||islower(c)) return 5;
	return 10;
}
int cost3(char c)
{
	if (c == 'n') return 0;
	if (c == 'N'||islower(c)) return 5;
	return 10;
}
int cost4(char c)
{
	if (c == 'd') return 0;
	if (c == 'D'||islower(c)) return 5;
	return 10;
}
int cost5(char c)
{
	if (c == 'r') return 0;
	if (c == 'R'||islower(c)) return 5;
	return 10;
}
int cost6(char c)
{
	if (c == 'o') return 0;
	if (c == 'O'||islower(c)) return 5;
	return 10;
}

int main()
{
	char s[205];
	while (cin >> s)
	{
		int len = strlen(s);
		int ans = 60;
		int temp;
		for (int i = 0; i < len - 5; i++)
		{
			temp = cost1(s[i]) + cost2(s[i + 1]) + cost3(s[i + 2]) + cost4(s[i + 3]) + cost5(s[i + 4]) + cost6(s[i + 5]);
			ans = min(ans, temp);
		}
		cout << ans << endl;
	}
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

这波lucio来全学了

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值