比赛 |
20110412 |
评测结果 |
AAEEEEEEEA |
题目名称 |
双亲数 |
最终得分 |
30 |
用户昵称 |
wo shi 刘畅 |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2011-04-12 11:14:28 |
显示代码纯文本
var
d,i,j,k,a,b:longint;
f:array[0..1000,0..1000]of longint;
function min(x,y:longint):longint;
begin
if x<y then exit(x);
exit(y);
end;
function go(x,y:longint):longint;
var
i,t:longint;
begin
if (x<=1000)and(y<=1000)and(f[x,y]<>-9) then exit(f[x,y]);
t:=x*y;
for i:=2 to min(x,y) do dec(t,go((x div i),(y div i)));
f[x,y]:=t;
exit(t);
end;
begin
assign(input,'parents.in');reset(input);
assign(output,'parents.out');rewrite(output);
for i:=0 to 1000 do
for j:=0 to 1000 do
f[i,j]:=-9;
f[0,0]:=0;
readln(a,b,d);
if (a=d)or(b=0) then writeln(0)
else writeln(go((a div d),(b div d)));
close(input);
close(output);
end.