求字典序在s1和s2之间的,长度在len1到len2的字符串的个数,结果mod 1000007。
public class Main {
public static long get(String a,String b,intmin)
{
long suma=0;
long sumb=0;
char[] ar=a.toCharArray();
char[] br=b.toCharArray();
for(inti=0;i<ar.length;i++)
{
suma=suma+(ar[i]-'a')*(long)Math.pow(26,min-1-i);
}
if(ar.length!=0)
{
suma++;
}
for(inti=0;i<br.length;i++)
{
sumb=sumb+(br[i]-'a')*(long)Math.pow(26,min-1-i);
}
if(br.length!=0)
{
sumb++;
}
returnsumb-suma;
}
publicstaticvoidmain(String[] args)
{
Scanner scan=newScanner(System.in);
while(scan.hasNext())
{
String s=scan.nextLine();
String[] array=s.split(" ");
intmin=Integer.parseInt(array[2]);
intmax=Integer.parseInt(array[3]);
longsum=0;
for(inti=min;i<=max;i++)
{
chara=array[0].charAt(0);
charb=array[1].charAt(0);
sum=sum+(long)Math.pow(26,i-1)*(b-a);
String la=array[0].substring(1, i < array[0].length() ? i : array[0].length());
String lb=array[1].substring(1, i < array[1].length() ? i : array[1].length());
sum=sum+get(la,lb,i-1);
}
longres=sum-1;
System.out.println(res%1000007);
}
}
}