Thứ Ba, 3 tháng 5, 2022

THOIGIAN C++

#include <bits/stdc++.h>
using namespace std;
int i,j,x,y,s;
int n[10]={2,0,3,3,1,3,3,1,3,3};
int d[10]={4,2,2,2,3,2,3,2,4,3};
void nhap()
{
    scanf("%d %d",&x,&y);
}
int ngang(int x, int y)
{
    s=0;
    if (x<10) s+=n[x];
    else s+=n[x%10]+n[x/10];
    if (y<10) s+=n[0]+n[y];
    else s+=n[y%10]+n[y/10];
    return s;
}

int doc(int x,int y)
{
    s=0;
    if (x<10) s+=d[x];
    else s+=d[x%10]+d[x/10];
    if (y<10) s+=d[0]+d[y];
    else s+=d[y%10]+d[y/10];
    return s;
}
void xuat(int x,int y)
{
    cout<<x<<":";
    if(y<10) cout<<"0";
    cout<<y;
}
void xuli()
{
    for (i=0;i<=23;i++)
    {
        for (j=0;j<=59;j++)
        {
            if ( ngang(i,j)==y && doc(i,j)==x )
            {
                xuat(i,j);
                return;
            }
        }

    }
    return;
}
int main()
{
    freopen("thoigian.inp","r",stdin);
    freopen("thoigian.out","w",stdout);
    nhap();
    xuli();
}

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.