zoukankan      html  css  js  c++  java
  • hdu 4207

    http://acm.hdu.edu.cn/showproblem.php?pid=4207

    两个数都不会超过六位数 所以可以直接用64位int 不会溢出

    只要注意输出格式 就好了

    #include<iostream>
    #include<string.h>
    using namespace std;
    __int64 a;
    int max1;
    int count(__int64 x)
    {
        int t=0;
        while(x)
        {
            x/=10;
            t++;
        }
        return t;
    }
    void solve(int temp,int c,int p)
    {
        __int64 v,i,ans;
       
        if(c==-1)
        {
            c=0;
            ans=temp;
            v=count(temp);
        }
        else
        {
            ans=temp*a;
            v=count(ans);
           
        }
        for(i=max1-v-c;i>0;i--)
            printf(" ");
        printf("%I64d",ans);
        while(p--)
            printf("0");
        printf("\n");
    }

    int main()
    {
        int i,j,temp,c,u=1;
        __int64 ans,b,t;
        while(scanf("%I64d%I64d",&a,&b))
        {
            if(a==0&&b==0)
                break;
            printf("Problem %d\n",u++);
            t=b;c=0;
            max1=count(a*b);
            solve(a,-1,0);
            solve(b,-1,0);
            for(i=0;i<max1;i++)
                printf("-");
            printf("\n");
            int p=0;
            int m=0;
            while(t)
            {
                temp=t%10;
                if(temp)
                {   m++;
                    solve(temp,c,p);
                    p=0;
                }
                else
                    p++;
                t/=10;
                c++;
            }
            if(m==1)
                continue;
            for(i=0;i<max1;i++)
                printf("-");
            printf("\n");
            printf("%I64d\n",a*b);
        }
        return 0;
    }
           

       

  • 相关阅读:
    电脑快捷键大全
    js实现页面跳转
    List转换为字符串方法
    Bootstrap4显示和隐藏元素
    反向代理和正向代理区别
    springboot系列一:工作环境无法联网下快速搭建boot项目
    英语故事系列:冠状病毒传播或导致2020首季度全球经济出现萎缩
    BBS网站的制作
    Flask-SQLAlchemy数据库操作
    step-by-step install Nginx反向代理服务器(Ubuntu 18.04 LTS)(转)
  • 原文地址:https://www.cnblogs.com/assult/p/3051789.html
Copyright © 2011-2022 走看看