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;
    }
           

       

  • 相关阅读:
    NOI2017 游戏
    2-SAT问题的方案输出
    hdu 2433 Travel
    bzoj千题计划230:bzoj3205: [Apio2013]机器人
    bzoj千题计划229:bzoj4424: Cf19E Fairy
    hdu 6166 Senior Pan
    poj 2404 Jogging Trails
    Oracle 删除数据后释放数据文件所占磁盘空间
    安装LINUX X86-64的10201出现链接ins_ctx.mk错误
    10G之后统计信息收集后为什么执行计划不会被立马淘汰
  • 原文地址:https://www.cnblogs.com/assult/p/3051789.html
Copyright © 2011-2022 走看看