比赛 |
20111104 |
评测结果 |
AAAATATTTA |
题目名称 |
方程 |
最终得分 |
60 |
用户昵称 |
reamb |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2011-11-04 21:52:44 |
显示代码纯文本
program equationz;
var
a:Array[0..32]of int64;
t,k,m,n,i,j,ans:longint;
f:array[1..100,1..1000]of ansistring;
procedure quick(i,j:longint);
var
t,k,l:longint;
p:int64;
begin
a[0]:=1;
a[1]:=i mod 100000;
for t:=2 to 32 do
a[t]:=(a[t-1]*a[t-1])mod 1000;
t:=0;
l:=j;
repeat
inc(t);
k:=l and 1;
if k=1 then
ans:=(ans*a[t])mod 1000;
l:=l shr 1;
until l=0;
end;
function add(s1,s2:ansistring):ansistring;
var
a,b,c:array[0..10000]of integer;
t,k,i,j:longint;
s:ansistring;
begin
fillchar(a,sizeof(a),0);
fillchar(b,sizeof(b),0);
fillchar(c,sizeof(c),0);
if s1='' then exit(s2);
if s2='' then exit(s1);
a[0]:=length(s1);b[0]:=length(s2);
for t:=1 to a[0] do
a[t]:=ord(s1[a[0]-t+1])-ord('0');
for t:=1 to b[0] do
b[t]:=ord(s2[b[0]-t+1])-ord('0');
if a[0]>b[0] then i:=a[0] else i:=b[0];
for t:=1 to i do
begin
c[t]:=a[t]+b[t]+c[t];
if c[t]>9 then
begin
c[t+1]:=c[t] div 10;
c[t]:=c[t] mod 10;
end;
end;
if c[i+1]>0 then c[0]:=i+1 else c[0]:=i;
s:='';
for t:=c[0] downto 1 do
s:=s+chr(ord('0')+c[t]);
exit(s);
end;
begin
assign(input,'equationz.in');
reset(input);
assign(output,'equationz.out');
rewrite(output);
readln(n,m);
ans:=1;
quick(m,m);
if ans<n then
begin
writeln(0);
close(output);
halt;
end;
for i:=1 to ans do
f[1,i]:='1';
for i:=2 to n do
for j:=i to ans do
f[i,j]:=add(f[i,j-1],f[i-1,j-1]);
writeln(f[n,ans]);
close(output);
end.