http://codevs.cn/problem/1376/
枚举修改哪两位,将sum减去之前位置的数+交换之后 %m==0即可
预处理26的次方+O(n^2)
// <1376.cpp> - Tue Oct 18 21:50:03 2016
// This file is made by YJinpeng,created by XuYike's black technology automatically.
// Copyright (C) 2016 ChangJun High School, Inc.
// I don't know what this program is. #include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;
typedef long long LL;
const int MAXN=;
char s[MAXN];int mul[MAXN];
int main()
{
freopen("1376.in","r",stdin);
freopen("1376.out","w",stdout);
scanf("%s",s);
int n=strlen(s),sum=,m;
mul[n-]=;scanf("%d",&m);
for(int i=n-;i;i--)
(sum+=mul[i]*(s[i]-'A')%m)%=m,mul[i-]=mul[i]*%m;
(sum+=mul[]*(s[]-'A')%m)%=m;
if(sum==){printf("0 0");return ;}
for(int i=;i<n;i++)
for(int j=i+;j<n;j++){
if(((sum+(s[i]-'A')*(mul[j]-mul[i]+m)%m)%m+(s[j]-'A')*(mul[i]-mul[j]+m)%m)%m==){
printf("%d %d",i+,j+);return ;
}
}printf("-1 -1");
return ;
}