比赛 20130725暑期B班1测 评测结果 TTTTTTTTTTTTTT
题目名称 残酷的数学老师 最终得分 0
用户昵称 o_o 运行时间 14.000 s
代码语言 Pascal 内存使用 0.54 MiB
提交时间 2012-07-18 10:21:53
显示代码纯文本
  1. var
  2. n,m,w:longint;
  3. i,j:longint;
  4. out:array[1..50000] of longint;
  5. sta:array[1..50000] of longint;
  6. procedure solve(n:longint);
  7. begin
  8. if n=0 then
  9. exit;
  10. solve(n div m);
  11.  
  12. for i:=1 to 15000 do
  13. for j:=1 to 15000 do
  14. if n mod m=0
  15. then
  16. sta[i+j-1]:=sta[i+j-1]+out[i]*out[j]
  17. else
  18. sta[i+j-1]:=sta[i+j-1]+out[i]*out[j]*m;
  19. for i:=1 to 15000 do
  20. begin
  21. out[i]:=sta[i] mod 10;
  22. sta[i+1]:=sta[i+1]+sta[i] div 10;
  23. end;
  24. for i:=1 to 15000 do sta[i]:=0;
  25.  
  26. end;
  27. begin
  28. assign(input,'cruel1.in');
  29. assign(output,'cruel1.out');
  30. reset(input);
  31. rewrite(output);
  32. readln(m,n);
  33.  
  34. out[1]:=1;
  35. solve(n);
  36. for i:=15000 downto 1 do
  37. begin
  38. if out[i]<>0 then
  39. begin
  40. write(out[i]);
  41. w:=w+1;
  42. end;
  43. if (w mod 70=1)and(w<>1) then writeln;
  44. end;
  45. close(input);
  46. close(output);
  47. end.