Thứ Ba, 3 tháng 5, 2022

THOIGIAN PASCAL

var v,h:longint;
    d:array[0..9]of longint=(4,2,2,2,3,2,3,2,4,3);
    n:array[0..9]of longint=(2,0,3,3,1,3,3,1,3,3);

procedure nhap;
begin
        readln(v,h);
end;

function so_gach_dung(h,p:longint):longint;
var s:longint;
begin
    s:=0;
    // tim so gach dung cua gio
    if h < 10 then s:=s+d[h]
     else s:=s+d[h mod 10]+d[h div 10];
    // tim so gach dung cua phut
    if p < 10 then s:=s+d[0]+d[p]
    else s:=s+d[p mod 10] + d[p div 10];
    exit(s);
end;

function so_gach_ngang(h,p:longint):longint;
var s,a:longint;
begin
    s:=0;
    // tim so gach ngang cua gio
    if h < 10 then s:=s+n[h]
    else s:=s+n[h mod 10]+n[h div 10];
    // tim so gach ngang cua phut
    if p < 10 then s:=s+n[0]+n[p]
    else s:=s+n[p mod 10] + n[p div 10];
    exit(s);
end;

procedure xuat(h,p:longint);
begin
    write(h,':');
    if p<10 then write('0');
    write(p);
end;

procedure xuli;
var i,j:longint;
begin
    for i:=0 to 23 do
        for j:=0 to 59 do
            if (so_gach_dung(i,j)=v) and (so_gach_ngang(i,j)=h) then
            begin
                xuat(i,j);
                exit;
            end;
end;

begin
    assign(input, 'thoigian.inp');reset(input);
    assign(output, 'thoigian.out');rewrite(output);
    nhap;
    xuli;
    end.


Không có nhận xét nào:

Đăng nhận xét

Lưu ý: Chỉ thành viên của blog này mới được đăng nhận xét.