记录编号 |
10913 |
评测结果 |
AAAAAAAAAA |
题目名称 |
[NOIP 2003]麦森数 |
最终得分 |
100 |
用户昵称 |
苏轼 |
是否通过 |
通过 |
代码语言 |
Pascal |
运行时间 |
0.222 s |
提交时间 |
2009-07-07 18:22:27 |
内存使用 |
0.19 MiB |
显示代码纯文本
Program mason (Input, Output);
//Uses
// Math;
Type
NUMBER= Array [ 1..601 ] Of Word;
NUMSET= Array [ 0..22 ] Of NUMBER;
Var
maxmi, p, i, tt: Cardinal;
save: NUMSET;
ans, tmp: NUMBER;
Procedure SuperMul (Var na, nb, ans: NUMBER);
Var
i, j: Word;
Begin
For i:= 1 To 600 Do
For j:= 1 To 600-i Do
ans[i+j-1] := na[i] * nb[j] + ans[i+j-1];
For i:= 1 To 600 Do
If ans[i]>=10 Then
Begin
ans[i+1]:= ans[i+1] + ans[i] DIV 10;
ans[i]:= ans[i] MOD 10;
End;
End;
Function Power(a, b:Cardinal): Cardinal;
Var
i, ans: Word;
Begin
ans:=1;
Power:=ans shl b;
End;
Begin
Assign (Input, 'mason.in');
Reset (Input);
Assign (Output, 'mason.out');
Rewrite (Output);
Readln (p);
Writeln(trunc(p*ln(2)/ln(10))+1);
Repeat
Inc (maxmi);
Until Power (2, maxmi) > p;
Dec (maxmi);
save[0][1]:=2;
For i:=1 To maxmi Do
SuperMul (save[i-1], save[i-1], save[i]);
ans[1]:=1;
Repeat
tt:=1;
For i:= 1 To maxmi Do
tt:= tt * 2;
p:= p - tt;
tmp:= ans;
Fillchar (ans, sizeof(ans), 0);
SuperMul (tmp, save[maxmi], ans);
maxmi:= 0;
Repeat
Inc (maxmi);
Until Power (2, maxmi) > p;
Dec (maxmi);
Until p=0;
Write (ans[500]);
For i:= 499 DownTo 2 Do
Begin
If i MOD 50=0 Then
Writeln;
Write (ans[i]);
End;
Writeln (ans[1]-1);
Close (Input);
Close (output);
End.