- 火柴棒等式
- 2014-07-29 22:08:32 @
const
c:array[0..9] of longint=(6,2,5,5,4,5,6,3,7,6);
var
a:array[0..1111]of longint;
ans,k,i,j,n:longint;
begin
for i:=0 to 9 do a[i]:=c[i];
for i:=10 to 1111 do
a[i]:=a[i div 10]+a[i mod 10];
read(n);
dec(n,4);
ans:=0;
for i:=1 to 1111 do
for j:=0 to i do
begin
k:=i-j;
if (a[i]+a[j]+a[k]=n) then inc(ans);
end;
writeln(ans);
end.
2 条评论
-
一方T行 LV 10 @ 2014-08-02 17:44:51
当时连const都不会用,,,太逗了
-
2014-08-02 17:44:10@
初一时写的,看得有点长。。。
program p1496;
var a:array[0..1000] of longint;
n,num:longint;
//
procedure init;
var i:longint;
begin
read(n);
end;
//
function kk(l:longint):longint;
begin
case l of
0:kk:=6;
1:kk:=2;
2:kk:=5;
3:kk:=5;
4:kk:=4;
5:kk:=5;
6:kk:=6;
7:kk:=3;
8:kk:=7;
9:kk:=6;
end;
end;
//
procedure makea(k:longint);
var n,l:longint;
begin
n:=k;
while n<>0 do
begin
l:=n mod 10;
inc(a[k],kk(l));
n:=n div 10;
end;
end;
//
procedure main;
var i,j:longint;
begin
a[0]:=6;
for i:=1 to 1000 do
begin
makea(i);
end;
for i:=0 to 1000 do
for j:=0 to 1000 do
if (i+j<=1000) then
if (a[i]+a[j]+a[i+j]+4=n) then
begin
inc(num);
end;
end;
//
procedure print;
begin
write(num);
end;
//
begin
init;
main;
print;
end.
- 1