URAL 1786 Sandro's Biography

1786. Sandro's Biography

Time limit: 1.0 second
Memory limit: 64 MB
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 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”.
Problem Author: Olga Soboleva 
Problem Source: Ural Regional School Programming Contest 2010


使用朴素的查找即可;


#include<iostream>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<stack>
#include<queue>
#include<iomanip>
#include<map>
#include<set>
#define pi 3.14159265358979323846
using namespace std;
char s[210];
int main()
{
    scanf("%s",&s);
    int len=strlen(s);
    int cnt,ans=1000;
    for(int i=0;i<=len-6;++i)
    {
        cnt=0;
        if(s[i]!='S')
        {
            if(s[i]=='s'||(s[i]>='A'&&s[i]<='Z'))
                ++cnt;
            else
                cnt+=2;
        }
        if(s[i+1]!='a')
        {
            if(s[i+1]=='A'||(s[i+1]>='a'&&s[i+1]<='z'))
                ++cnt;
            else
                cnt+=2;
        }
        if(s[i+2]!='n')
        {
            if(s[i+2]=='N'||(s[i+2]>='a'&&s[i+2]<='z'))
                ++cnt;
            else
                cnt+=2;
        }
        if(s[i+3]!='d')
        {
            if(s[i+3]=='D'||(s[i+3]>='a'&&s[i+3]<='z'))
                ++cnt;
            else
                cnt+=2;
        }
        if(s[i+4]!='r')
        {
            if(s[i+4]=='R'||(s[i+4]>='a'&&s[i+4]<='z'))
                ++cnt;
            else
                cnt+=2;
        }
        if(s[i+5]!='o')
        {
            if(s[i+5]=='O'||(s[i+5]>='a'&&s[i+5]<='z'))
                ++cnt;
            else
                cnt+=2;
        }
        ans=min(ans,cnt);
    }
    int zans=5*ans;
    printf("%d\n",zans);
    return 0;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值