一个让我爆零的水题,,,,,
codeforces 1151A 1000分
题意:一个字符串,单个字符可以一步可以变成左右两个(Z可以变成Y,A),问最低多少步可以产生“ACTG”;
错因:错误的理解了s[i]-'0'的含义了,0的ASCLL码是48!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <map>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <vector>
//const int maxn = 1e5+5;
#define ll long long
//#define MAX INT_MAX
#define FOR(i,a,b) for( int i = a;i <= b;++i)
//#define MOD 142857
using namespace std;
char c;
int n,minn=INT_MAX,ans1,ans2,ans3,ans4,sum,a,b,ans;
string s;
int main()
{
// freopen("D:\\common_text\\code_stream\\in.txt","r",stdin);
// freopen("D:\\common_text\\code_stream\\out.txt","w",stdout);
cin>>n>>s;
for(int i=0;i<=n-4;++i)
{
sum=;
int a=abs(s[i]-'A');
int b=abs(s[i+]-'C');
int c=abs(s[i+]-'T');
int d=abs(s[i+]-'G');
sum+=min(a,-a)+min(b,-b)+min(c,-c)+min(d,-d);
if(minn>sum)
minn=sum;
}
cout<<minn;
}