题意:

思路:

 const mo=;
var pow,f,exf:array[-..]of int64;
n,k,i:longint;
ans,x,y:int64;
s,t:ansistring; function c(x,y:longint):int64;
begin
exit(f[x]*exf[y] mod mo*exf[x-y] mod mo);
end; function min(x,y:int64):int64;
begin
if x<y then exit(x);
exit(y);
end; begin
assign(input,'1.in'); reset(input);
assign(output,'1.out'); rewrite(output);
readln(n,k);
readln(s);
readln(t);
pow[]:=;
for i:= to n do pow[i]:=pow[i-]* mod mo;
f[]:=;
for i:= to n do f[i]:=f[i-]*i mod mo;
exf[]:=; exf[]:=;
for i:= to n do exf[i]:=exf[mo mod i]*(mo-mo div i) mod mo;
for i:= to n do exf[i]:=exf[i-]*exf[i] mod mo;
ans:=;
for i:= to n do
begin
x:=ord(t[i])-ord('a'); y:=ord(s[i])-ord('a');
ans:=(ans+min(x,y)*c(n-i,k-) mod mo*pow[k-] mod mo) mod mo;
if s[i]<t[i] then
begin
ans:=(ans+c(n-i,k)*pow[k] mod mo) mod mo;
ans:=(ans+(x-y-)*c(n-i,k-) mod mo*pow[k-] mod mo) mod mo;
end;
if s[i]<>t[i] then dec(k);
end;
writeln(ans);
close(input);
close(output);
end.

最新文章

  1. Docker学习笔记第一章:补充
  2. JAVA获取CLASSPATH路径
  3. [转]Hibernate与Jpa的关系,终于弄懂
  4. JVM调优-Java中的对象
  5. STM32普通定时器实现延时函数
  6. js事件3
  7. 改进RazorPad
  8. drupal错误: Maximum execution time of 240 seconds exceeded
  9. swift学习 - tableView自适应高度2(SnapKit Layout)
  10. .NET 实现Base-64加密解密处理
  11. Ubuntu配置Django+ Apache2+ mysql
  12. python中的进程池
  13. Nginx负载均衡和反向代理的配置和优化
  14. Confluence 6 外部小工具在其他应用中设置可信关系
  15. 通过使用浏览器对象模型,输出当前浏览器窗口中打开的文档的URL信息,并将显示在窗口中。
  16. 超强、超详细Redis入门教程【转】
  17. 利用Docker搭建java项目开发环境
  18. python面试题(转)
  19. oracle 中的exists 和 in 效率问题
  20. JZYZOJ1539[haoi2015]T2 树链剖分

热门文章

  1. USACO08FEB Hotel
  2. 利用ss5服务搭建代理服务器
  3. loj6485 LJJ 学二项式定理
  4. NodeJS基础入门-Buffer
  5. php读取不到https的域名
  6. 2-python基础
  7. 如何使用jmeter做接口测试
  8. day 35 补充
  9. SpringMVC总结以及在面试中的一些问题.
  10. Python基础-os模块 sys模块