1. 程式人生 > >zzuli:小G的日常之算術題

zzuli:小G的日常之算術題

http://acm.zzuli.edu.cn/problem.php?id=2395

 

題目描述

小G是出了名的學霸,各種問題到他手中都迎刃而解,聽說要出新生周賽題,那來個簡單的a+b吧。
現給你一個a和一個b,請計算他們的a+b的和是多少
請注意,要輸出的是:

#####......#..#####..#####..#...#..#####..#####..#####..#####..#####
#...#......#......#......#..#...#..#......#..........#..#...#..#...#
#...#......#..#####..#####..#####..#####..#####......#..#####..#####
#...#......#..#..........#......#......#..#...#......#..#...#......#
#####......#..#####..#####......#..#####..#####......#..#####..#####

輸入

兩個整數a,b(0<=a,b<1e9)

 

輸出

a+b的和,請看樣例輸出。

 

樣例輸入

123 456

 

樣例輸出

#####..#####..#####
#..........#..#...#
#####......#..#####
....#......#......#
#####......#..#####
#include<stdio.h>
#include<math.h>
char a[100]="#####....############...##########################";
char b[100]="#...#....#....#....##...##....#........##...##...#";
char c[100]="#...#....##########################....###########";
char d[100]="#...#....##........#....#....##...#....##...#....#";
char e[100]="#####....###########....###########....###########";
int main()
{
    int ans[10];
    long long y,z,sum,sum1,n;
    int i,len,j,x;
    scanf("%lld%lld",&z,&y);
    sum=z+y;
     
    if(sum==0)
        len=1;
    else len=log10(sum)+1;
    for(i=1;i<=len;i++)
    {
        sum1=pow(10,len-i);
        x=sum/sum1;
        ans[i]=x;
        sum=sum%sum1;
    }
     
    for(i=1;i<=len;i++)
    {
        x=ans[i];
        for(j=x*5;j<(x+1)*5;j++)
            printf("%c",a[j]);
        if(i!=len)
            printf("..");
    }
    printf("\n");
    for(i=1;i<=len;i++)
    {
        x=ans[i];
        for(j=x*5;j<(x+1)*5;j++)
            printf("%c",b[j]);
        if(i!=len)
            printf("..");
    }
    printf("\n");
    for(i=1;i<=len;i++)
    {
        x=ans[i];
        for(j=x*5;j<(x+1)*5;j++)
            printf("%c",c[j]);
        if(i!=len)
            printf("..");
    }
    printf("\n");
    for(i=1;i<=len;i++)
    {
        x=ans[i];
        for(j=x*5;j<(x+1)*5;j++)
            printf("%c",d[j]);
        if(i!=len)
            printf("..");
    }
    printf("\n");
    for(i=1;i<=len;i++)
    {
        x=ans[i];
        for(j=x*5;j<(x+1)*5;j++)
            printf("%c",e[j]);
        if(i!=len)
            printf("..");
    }
    printf("\n");
    return 0;
}